mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-22 20:08:46 +00:00
feat(notifications): integrate dokployBackup into notification handling
- Added dokployBackup parameter to various notification functions and schemas to support backup notifications. - Updated HandleNotifications component to include dokployBackup in notification payloads. - Enhanced notification utilities to accommodate new backup notification types across multiple channels.
This commit is contained in:
@@ -421,6 +421,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: notification.appDeploy,
|
appDeploy: notification.appDeploy,
|
||||||
dokployRestart: notification.dokployRestart,
|
dokployRestart: notification.dokployRestart,
|
||||||
databaseBackup: notification.databaseBackup,
|
databaseBackup: notification.databaseBackup,
|
||||||
|
dokployBackup: notification.dokployBackup,
|
||||||
volumeBackup: notification.volumeBackup,
|
volumeBackup: notification.volumeBackup,
|
||||||
type: notification.notificationType,
|
type: notification.notificationType,
|
||||||
apiKey: notification.resend?.apiKey,
|
apiKey: notification.resend?.apiKey,
|
||||||
@@ -469,6 +470,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: notification.appDeploy,
|
appDeploy: notification.appDeploy,
|
||||||
dokployRestart: notification.dokployRestart,
|
dokployRestart: notification.dokployRestart,
|
||||||
databaseBackup: notification.databaseBackup,
|
databaseBackup: notification.databaseBackup,
|
||||||
|
dokployBackup: notification.dokployBackup,
|
||||||
volumeBackup: notification.volumeBackup,
|
volumeBackup: notification.volumeBackup,
|
||||||
type: notification.notificationType,
|
type: notification.notificationType,
|
||||||
webhookUrl: notification.mattermost?.webhookUrl,
|
webhookUrl: notification.mattermost?.webhookUrl,
|
||||||
@@ -498,6 +500,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: notification.appDeploy,
|
appDeploy: notification.appDeploy,
|
||||||
dokployRestart: notification.dokployRestart,
|
dokployRestart: notification.dokployRestart,
|
||||||
databaseBackup: notification.databaseBackup,
|
databaseBackup: notification.databaseBackup,
|
||||||
|
dokployBackup: notification.dokployBackup,
|
||||||
volumeBackup: notification.volumeBackup,
|
volumeBackup: notification.volumeBackup,
|
||||||
type: notification.notificationType,
|
type: notification.notificationType,
|
||||||
webhookUrl: notification.teams?.webhookUrl,
|
webhookUrl: notification.teams?.webhookUrl,
|
||||||
@@ -511,6 +514,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: notification.appDeploy,
|
appDeploy: notification.appDeploy,
|
||||||
dokployRestart: notification.dokployRestart,
|
dokployRestart: notification.dokployRestart,
|
||||||
databaseBackup: notification.databaseBackup,
|
databaseBackup: notification.databaseBackup,
|
||||||
|
dokployBackup: notification.dokployBackup,
|
||||||
type: notification.notificationType,
|
type: notification.notificationType,
|
||||||
endpoint: notification.custom?.endpoint || "",
|
endpoint: notification.custom?.endpoint || "",
|
||||||
headers: notification.custom?.headers
|
headers: notification.custom?.headers
|
||||||
@@ -532,6 +536,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: notification.appDeploy,
|
appDeploy: notification.appDeploy,
|
||||||
dokployRestart: notification.dokployRestart,
|
dokployRestart: notification.dokployRestart,
|
||||||
databaseBackup: notification.databaseBackup,
|
databaseBackup: notification.databaseBackup,
|
||||||
|
dokployBackup: notification.dokployBackup,
|
||||||
volumeBackup: notification.volumeBackup,
|
volumeBackup: notification.volumeBackup,
|
||||||
type: notification.notificationType,
|
type: notification.notificationType,
|
||||||
userKey: notification.pushover?.userKey,
|
userKey: notification.pushover?.userKey,
|
||||||
@@ -651,6 +656,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: appDeploy,
|
appDeploy: appDeploy,
|
||||||
dokployRestart: dokployRestart,
|
dokployRestart: dokployRestart,
|
||||||
databaseBackup: databaseBackup,
|
databaseBackup: databaseBackup,
|
||||||
|
dokployBackup: dokployBackup,
|
||||||
volumeBackup: volumeBackup,
|
volumeBackup: volumeBackup,
|
||||||
apiKey: data.apiKey,
|
apiKey: data.apiKey,
|
||||||
fromAddress: data.fromAddress,
|
fromAddress: data.fromAddress,
|
||||||
@@ -701,6 +707,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: appDeploy,
|
appDeploy: appDeploy,
|
||||||
dokployRestart: dokployRestart,
|
dokployRestart: dokployRestart,
|
||||||
databaseBackup: databaseBackup,
|
databaseBackup: databaseBackup,
|
||||||
|
dokployBackup: dokployBackup,
|
||||||
volumeBackup: volumeBackup,
|
volumeBackup: volumeBackup,
|
||||||
webhookUrl: data.webhookUrl,
|
webhookUrl: data.webhookUrl,
|
||||||
channel: data.channel || undefined,
|
channel: data.channel || undefined,
|
||||||
@@ -732,6 +739,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: appDeploy,
|
appDeploy: appDeploy,
|
||||||
dokployRestart: dokployRestart,
|
dokployRestart: dokployRestart,
|
||||||
databaseBackup: databaseBackup,
|
databaseBackup: databaseBackup,
|
||||||
|
dokployBackup: dokployBackup,
|
||||||
volumeBackup: volumeBackup,
|
volumeBackup: volumeBackup,
|
||||||
webhookUrl: data.webhookUrl,
|
webhookUrl: data.webhookUrl,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
@@ -758,6 +766,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: appDeploy,
|
appDeploy: appDeploy,
|
||||||
dokployRestart: dokployRestart,
|
dokployRestart: dokployRestart,
|
||||||
databaseBackup: databaseBackup,
|
databaseBackup: databaseBackup,
|
||||||
|
dokployBackup: dokployBackup,
|
||||||
volumeBackup: volumeBackup,
|
volumeBackup: volumeBackup,
|
||||||
endpoint: data.endpoint,
|
endpoint: data.endpoint,
|
||||||
headers: headersRecord,
|
headers: headersRecord,
|
||||||
@@ -777,6 +786,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
appDeploy: appDeploy,
|
appDeploy: appDeploy,
|
||||||
dokployRestart: dokployRestart,
|
dokployRestart: dokployRestart,
|
||||||
databaseBackup: databaseBackup,
|
databaseBackup: databaseBackup,
|
||||||
|
dokployBackup: dokployBackup,
|
||||||
volumeBackup: volumeBackup,
|
volumeBackup: volumeBackup,
|
||||||
userKey: data.userKey,
|
userKey: data.userKey,
|
||||||
apiToken: data.apiToken,
|
apiToken: data.apiToken,
|
||||||
|
|||||||
@@ -396,6 +396,7 @@ export const apiCreateResend = notificationsSchema
|
|||||||
.pick({
|
.pick({
|
||||||
appBuildError: true,
|
appBuildError: true,
|
||||||
databaseBackup: true,
|
databaseBackup: true,
|
||||||
|
dokployBackup: true,
|
||||||
volumeBackup: true,
|
volumeBackup: true,
|
||||||
dokployRestart: true,
|
dokployRestart: true,
|
||||||
name: true,
|
name: true,
|
||||||
@@ -493,6 +494,7 @@ export const apiCreateMattermost = notificationsSchema
|
|||||||
.pick({
|
.pick({
|
||||||
appBuildError: true,
|
appBuildError: true,
|
||||||
databaseBackup: true,
|
databaseBackup: true,
|
||||||
|
dokployBackup: true,
|
||||||
volumeBackup: true,
|
volumeBackup: true,
|
||||||
dokployRestart: true,
|
dokployRestart: true,
|
||||||
name: true,
|
name: true,
|
||||||
@@ -510,6 +512,7 @@ export const apiCreateMattermost = notificationsSchema
|
|||||||
webhookUrl: true,
|
webhookUrl: true,
|
||||||
appBuildError: true,
|
appBuildError: true,
|
||||||
databaseBackup: true,
|
databaseBackup: true,
|
||||||
|
dokployBackup: true,
|
||||||
volumeBackup: true,
|
volumeBackup: true,
|
||||||
dokployRestart: true,
|
dokployRestart: true,
|
||||||
appDeploy: true,
|
appDeploy: true,
|
||||||
@@ -542,6 +545,7 @@ export const apiCreateCustom = notificationsSchema
|
|||||||
.pick({
|
.pick({
|
||||||
appBuildError: true,
|
appBuildError: true,
|
||||||
databaseBackup: true,
|
databaseBackup: true,
|
||||||
|
dokployBackup: true,
|
||||||
volumeBackup: true,
|
volumeBackup: true,
|
||||||
dokployRestart: true,
|
dokployRestart: true,
|
||||||
name: true,
|
name: true,
|
||||||
@@ -596,6 +600,7 @@ export const apiCreateTeams = notificationsSchema
|
|||||||
.pick({
|
.pick({
|
||||||
appBuildError: true,
|
appBuildError: true,
|
||||||
databaseBackup: true,
|
databaseBackup: true,
|
||||||
|
dokployBackup: true,
|
||||||
volumeBackup: true,
|
volumeBackup: true,
|
||||||
dokployRestart: true,
|
dokployRestart: true,
|
||||||
name: true,
|
name: true,
|
||||||
@@ -622,6 +627,7 @@ export const apiCreatePushover = notificationsSchema
|
|||||||
.pick({
|
.pick({
|
||||||
appBuildError: true,
|
appBuildError: true,
|
||||||
databaseBackup: true,
|
databaseBackup: true,
|
||||||
|
dokployBackup: true,
|
||||||
volumeBackup: true,
|
volumeBackup: true,
|
||||||
dokployRestart: true,
|
dokployRestart: true,
|
||||||
name: true,
|
name: true,
|
||||||
@@ -656,6 +662,7 @@ export const apiUpdatePushover = z.object({
|
|||||||
expire: z.number().min(1).max(10800).nullish(),
|
expire: z.number().min(1).max(10800).nullish(),
|
||||||
appBuildError: z.boolean().optional(),
|
appBuildError: z.boolean().optional(),
|
||||||
databaseBackup: z.boolean().optional(),
|
databaseBackup: z.boolean().optional(),
|
||||||
|
dokployBackup: z.boolean().optional(),
|
||||||
volumeBackup: z.boolean().optional(),
|
volumeBackup: z.boolean().optional(),
|
||||||
dokployRestart: z.boolean().optional(),
|
dokployRestart: z.boolean().optional(),
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
|
|||||||
@@ -460,6 +460,7 @@ export const createResendNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
@@ -492,6 +493,7 @@ export const updateResendNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
@@ -741,6 +743,7 @@ export const createCustomNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
@@ -773,6 +776,7 @@ export const updateCustomNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
@@ -958,6 +962,7 @@ export const createTeamsNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
@@ -990,6 +995,7 @@ export const updateTeamsNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
@@ -1065,6 +1071,7 @@ export const createMattermostNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
@@ -1097,6 +1104,7 @@ export const updateMattermostNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
@@ -1161,6 +1169,7 @@ export const createPushoverNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
@@ -1193,6 +1202,7 @@ export const updatePushoverNotification = async (
|
|||||||
appDeploy: input.appDeploy,
|
appDeploy: input.appDeploy,
|
||||||
appBuildError: input.appBuildError,
|
appBuildError: input.appBuildError,
|
||||||
databaseBackup: input.databaseBackup,
|
databaseBackup: input.databaseBackup,
|
||||||
|
dokployBackup: input.dokployBackup,
|
||||||
volumeBackup: input.volumeBackup,
|
volumeBackup: input.volumeBackup,
|
||||||
dokployRestart: input.dokployRestart,
|
dokployRestart: input.dokployRestart,
|
||||||
dockerCleanup: input.dockerCleanup,
|
dockerCleanup: input.dockerCleanup,
|
||||||
|
|||||||
@@ -5,12 +5,17 @@ import { renderAsync } from "@react-email/components";
|
|||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
|
sendCustomNotification,
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
sendLarkNotification,
|
|
||||||
sendGotifyNotification,
|
sendGotifyNotification,
|
||||||
|
sendLarkNotification,
|
||||||
|
sendMattermostNotification,
|
||||||
sendNtfyNotification,
|
sendNtfyNotification,
|
||||||
|
sendPushoverNotification,
|
||||||
|
sendResendNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
|
sendTeamsNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
@@ -32,287 +37,380 @@ export const sendDokployBackupNotifications = async ({
|
|||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
|
resend: true,
|
||||||
gotify: true,
|
gotify: true,
|
||||||
ntfy: true,
|
ntfy: true,
|
||||||
|
mattermost: true,
|
||||||
|
custom: true,
|
||||||
lark: true,
|
lark: true,
|
||||||
|
pushover: true,
|
||||||
|
teams: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const notification of notificationList) {
|
for (const notification of notificationList) {
|
||||||
const { email, discord, telegram, slack, gotify, ntfy, lark } =
|
const {
|
||||||
notification;
|
email,
|
||||||
|
discord,
|
||||||
|
telegram,
|
||||||
|
slack,
|
||||||
|
resend,
|
||||||
|
gotify,
|
||||||
|
ntfy,
|
||||||
|
mattermost,
|
||||||
|
custom,
|
||||||
|
lark,
|
||||||
|
pushover,
|
||||||
|
teams,
|
||||||
|
} = notification;
|
||||||
|
|
||||||
if (email) {
|
try {
|
||||||
const template = await renderAsync(
|
if (email || resend) {
|
||||||
DokployBackupEmail({
|
const template = await renderAsync(
|
||||||
type,
|
DokployBackupEmail({
|
||||||
errorMessage,
|
type,
|
||||||
date: date.toLocaleString(),
|
errorMessage,
|
||||||
backupSize,
|
date: date.toLocaleString(),
|
||||||
}),
|
backupSize,
|
||||||
).catch();
|
}),
|
||||||
await sendEmailNotification(email, "Dokploy instance backup", template);
|
).catch();
|
||||||
}
|
|
||||||
|
|
||||||
if (discord) {
|
if (email) {
|
||||||
const decorate = (decoration: string, text: string) =>
|
await sendEmailNotification(
|
||||||
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
email,
|
||||||
|
"Dokploy instance backup",
|
||||||
|
template,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await sendDiscordNotification(discord, {
|
if (resend) {
|
||||||
title:
|
await sendResendNotification(
|
||||||
type === "success"
|
resend,
|
||||||
? decorate(">", "`✅` Dokploy Backup Successful")
|
"Dokploy instance backup",
|
||||||
: decorate(">", "`❌` Dokploy Backup Failed"),
|
template,
|
||||||
color: type === "success" ? 0x57f287 : 0xed4245,
|
);
|
||||||
fields: [
|
}
|
||||||
{
|
}
|
||||||
name: decorate("`📦`", "Backup Type"),
|
|
||||||
value: "Complete Dokploy Instance",
|
if (discord) {
|
||||||
inline: true,
|
const decorate = (decoration: string, text: string) =>
|
||||||
|
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
||||||
|
|
||||||
|
await sendDiscordNotification(discord, {
|
||||||
|
title:
|
||||||
|
type === "success"
|
||||||
|
? decorate(">", "`✅` Dokploy Backup Successful")
|
||||||
|
: decorate(">", "`❌` Dokploy Backup Failed"),
|
||||||
|
color: type === "success" ? 0x57f287 : 0xed4245,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: decorate("`📦`", "Backup Type"),
|
||||||
|
value: "Complete Dokploy Instance",
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
...(backupSize
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
name: decorate("`💾`", "Backup Size"),
|
||||||
|
value: backupSize,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
{
|
||||||
|
name: decorate("`📅`", "Date"),
|
||||||
|
value: `<t:${unixDate}:D>`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: decorate("`⌚`", "Time"),
|
||||||
|
value: `<t:${unixDate}:t>`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: decorate("`❓`", "Status"),
|
||||||
|
value: type
|
||||||
|
.replace("error", "Failed")
|
||||||
|
.replace("success", "Successful"),
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
...(type === "error" && errorMessage
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
name: decorate("`⚠️`", "Error Message"),
|
||||||
|
value: `\`\`\`${errorMessage}\`\`\``,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
],
|
||||||
|
timestamp: date.toISOString(),
|
||||||
|
footer: {
|
||||||
|
text: "Dokploy Instance Backup Notification",
|
||||||
},
|
},
|
||||||
...(backupSize
|
});
|
||||||
? [
|
}
|
||||||
{
|
|
||||||
name: decorate("`💾`", "Backup Size"),
|
|
||||||
value: backupSize,
|
|
||||||
inline: true,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
{
|
|
||||||
name: decorate("`📅`", "Date"),
|
|
||||||
value: `<t:${unixDate}:D>`,
|
|
||||||
inline: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: decorate("`⌚`", "Time"),
|
|
||||||
value: `<t:${unixDate}:t>`,
|
|
||||||
inline: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: decorate("`❓`", "Status"),
|
|
||||||
value: type
|
|
||||||
.replace("error", "Failed")
|
|
||||||
.replace("success", "Successful"),
|
|
||||||
inline: true,
|
|
||||||
},
|
|
||||||
...(type === "error" && errorMessage
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
name: decorate("`⚠️`", "Error Message"),
|
|
||||||
value: `\`\`\`${errorMessage}\`\`\``,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
],
|
|
||||||
timestamp: date.toISOString(),
|
|
||||||
footer: {
|
|
||||||
text: "Dokploy Instance Backup Notification",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gotify) {
|
if (gotify) {
|
||||||
const decorate = (decoration: string, text: string) =>
|
const decorate = (decoration: string, text: string) =>
|
||||||
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
||||||
|
|
||||||
await sendGotifyNotification(
|
await sendGotifyNotification(
|
||||||
gotify,
|
gotify,
|
||||||
decorate(
|
decorate(
|
||||||
type === "success" ? "✅" : "❌",
|
type === "success" ? "✅" : "❌",
|
||||||
|
`Dokploy Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
|
),
|
||||||
|
`${decorate("📦", "Backup Type: Complete Dokploy Instance")}` +
|
||||||
|
`${backupSize ? decorate("💾", `Backup Size: ${backupSize}`) : ""}` +
|
||||||
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
||||||
|
`${type === "error" && errorMessage ? decorate("❌", `Error:\n${errorMessage}`) : ""}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ntfy) {
|
||||||
|
await sendNtfyNotification(
|
||||||
|
ntfy,
|
||||||
`Dokploy Backup ${type === "success" ? "Successful" : "Failed"}`,
|
`Dokploy Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
),
|
`${type === "success" ? "white_check_mark" : "x"}`,
|
||||||
`${decorate("📦", "Backup Type: Complete Dokploy Instance")}` +
|
"",
|
||||||
`${backupSize ? decorate("💾", `Backup Size: ${backupSize}`) : ""}` +
|
"📦Backup Type: Complete Dokploy Instance\n" +
|
||||||
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
`${backupSize ? `💾Backup Size: ${backupSize}\n` : ""}` +
|
||||||
`${type === "error" && errorMessage ? decorate("❌", `Error:\n${errorMessage}`) : ""}`,
|
`🕒Date: ${date.toLocaleString()}\n` +
|
||||||
);
|
`${type === "error" && errorMessage ? `❌Error:\n${errorMessage}` : ""}`,
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (ntfy) {
|
if (telegram) {
|
||||||
await sendNtfyNotification(
|
const isError = type === "error" && errorMessage;
|
||||||
ntfy,
|
|
||||||
`Dokploy Backup ${type === "success" ? "Successful" : "Failed"}`,
|
|
||||||
`${type === "success" ? "white_check_mark" : "x"}`,
|
|
||||||
"",
|
|
||||||
`📦Backup Type: Complete Dokploy Instance\n` +
|
|
||||||
`${backupSize ? `💾Backup Size: ${backupSize}\n` : ""}` +
|
|
||||||
`🕒Date: ${date.toLocaleString()}\n` +
|
|
||||||
`${type === "error" && errorMessage ? `❌Error:\n${errorMessage}` : ""}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (telegram) {
|
const statusEmoji = type === "success" ? "✅" : "❌";
|
||||||
const isError = type === "error" && errorMessage;
|
const typeStatus = type === "success" ? "Successful" : "Failed";
|
||||||
|
const errorMsg = isError
|
||||||
|
? `\n\n<b>Error:</b>\n<pre>${errorMessage}</pre>`
|
||||||
|
: "";
|
||||||
|
const sizeInfo = backupSize
|
||||||
|
? `\n<b>Backup Size:</b> ${backupSize}`
|
||||||
|
: "";
|
||||||
|
|
||||||
const statusEmoji = type === "success" ? "✅" : "❌";
|
const messageText = `<b>${statusEmoji} Dokploy Backup ${typeStatus}</b>\n\n<b>Backup Type:</b> Complete Dokploy Instance${sizeInfo}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}${isError ? errorMsg : ""}`;
|
||||||
const typeStatus = type === "success" ? "Successful" : "Failed";
|
|
||||||
const errorMsg = isError
|
|
||||||
? `\n\n<b>Error:</b>\n<pre>${errorMessage}</pre>`
|
|
||||||
: "";
|
|
||||||
const sizeInfo = backupSize ? `\n<b>Backup Size:</b> ${backupSize}` : "";
|
|
||||||
|
|
||||||
const messageText = `<b>${statusEmoji} Dokploy Backup ${typeStatus}</b>\n\n<b>Backup Type:</b> Complete Dokploy Instance${sizeInfo}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}${isError ? errorMsg : ""}`;
|
await sendTelegramNotification(telegram, messageText);
|
||||||
|
}
|
||||||
|
|
||||||
await sendTelegramNotification(telegram, messageText);
|
if (slack) {
|
||||||
}
|
const { channel } = slack;
|
||||||
|
await sendSlackNotification(slack, {
|
||||||
|
channel: channel,
|
||||||
|
attachments: [
|
||||||
|
{
|
||||||
|
color: type === "success" ? "#00FF00" : "#FF0000",
|
||||||
|
pretext:
|
||||||
|
type === "success"
|
||||||
|
? ":white_check_mark: *Dokploy Backup Successful*"
|
||||||
|
: ":x: *Dokploy Backup Failed*",
|
||||||
|
fields: [
|
||||||
|
...(type === "error" && errorMessage
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
title: "Error Message",
|
||||||
|
value: errorMessage,
|
||||||
|
short: false,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
{
|
||||||
|
title: "Backup Type",
|
||||||
|
value: "Complete Dokploy Instance",
|
||||||
|
short: true,
|
||||||
|
},
|
||||||
|
...(backupSize
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
title: "Backup Size",
|
||||||
|
value: backupSize,
|
||||||
|
short: true,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
{
|
||||||
|
title: "Time",
|
||||||
|
value: date.toLocaleString(),
|
||||||
|
short: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Status",
|
||||||
|
value: type === "success" ? "Successful" : "Failed",
|
||||||
|
short: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (slack) {
|
if (lark) {
|
||||||
const { channel } = slack;
|
const limitCharacter = 800;
|
||||||
await sendSlackNotification(slack, {
|
const truncatedErrorMessage =
|
||||||
channel: channel,
|
errorMessage && errorMessage.length > limitCharacter
|
||||||
attachments: [
|
? errorMessage.substring(0, limitCharacter)
|
||||||
{
|
: errorMessage;
|
||||||
color: type === "success" ? "#00FF00" : "#FF0000",
|
|
||||||
pretext:
|
|
||||||
type === "success"
|
|
||||||
? ":white_check_mark: *Dokploy Backup Successful*"
|
|
||||||
: ":x: *Dokploy Backup Failed*",
|
|
||||||
fields: [
|
|
||||||
...(type === "error" && errorMessage
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
title: "Error Message",
|
|
||||||
value: errorMessage,
|
|
||||||
short: false,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
{
|
|
||||||
title: "Backup Type",
|
|
||||||
value: "Complete Dokploy Instance",
|
|
||||||
short: true,
|
|
||||||
},
|
|
||||||
...(backupSize
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
title: "Backup Size",
|
|
||||||
value: backupSize,
|
|
||||||
short: true,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
{
|
|
||||||
title: "Time",
|
|
||||||
value: date.toLocaleString(),
|
|
||||||
short: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Status",
|
|
||||||
value: type === "success" ? "Successful" : "Failed",
|
|
||||||
short: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lark) {
|
await sendLarkNotification(lark, {
|
||||||
const limitCharacter = 800;
|
msg_type: "interactive",
|
||||||
const truncatedErrorMessage =
|
card: {
|
||||||
errorMessage && errorMessage.length > limitCharacter
|
schema: "2.0",
|
||||||
? errorMessage.substring(0, limitCharacter)
|
config: {
|
||||||
: errorMessage;
|
update_multi: true,
|
||||||
|
style: {
|
||||||
await sendLarkNotification(lark, {
|
text_size: {
|
||||||
msg_type: "interactive",
|
normal_v2: {
|
||||||
card: {
|
default: "normal",
|
||||||
schema: "2.0",
|
pc: "normal",
|
||||||
config: {
|
mobile: "heading",
|
||||||
update_multi: true,
|
},
|
||||||
style: {
|
|
||||||
text_size: {
|
|
||||||
normal_v2: {
|
|
||||||
default: "normal",
|
|
||||||
pc: "normal",
|
|
||||||
mobile: "heading",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
header: {
|
||||||
header: {
|
title: {
|
||||||
title: {
|
tag: "plain_text",
|
||||||
tag: "plain_text",
|
content:
|
||||||
content:
|
type === "success"
|
||||||
type === "success"
|
? "✅ Dokploy Backup Successful"
|
||||||
? "✅ Dokploy Backup Successful"
|
: "❌ Dokploy Backup Failed",
|
||||||
: "❌ Dokploy Backup Failed",
|
|
||||||
},
|
|
||||||
subtitle: {
|
|
||||||
tag: "plain_text",
|
|
||||||
content: "",
|
|
||||||
},
|
|
||||||
template: type === "success" ? "green" : "red",
|
|
||||||
padding: "12px 12px 12px 12px",
|
|
||||||
},
|
|
||||||
body: {
|
|
||||||
direction: "vertical",
|
|
||||||
padding: "12px 12px 12px 12px",
|
|
||||||
elements: [
|
|
||||||
{
|
|
||||||
tag: "column_set",
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
tag: "column",
|
|
||||||
width: "weighted",
|
|
||||||
elements: [
|
|
||||||
{
|
|
||||||
tag: "markdown",
|
|
||||||
content: `**Backup Type:**\nComplete Dokploy Instance`,
|
|
||||||
text_align: "left",
|
|
||||||
text_size: "normal_v2",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "markdown",
|
|
||||||
content: `**Status:**\n${type === "success" ? "Successful" : "Failed"}`,
|
|
||||||
text_align: "left",
|
|
||||||
text_size: "normal_v2",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
vertical_align: "top",
|
|
||||||
weight: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "column",
|
|
||||||
width: "weighted",
|
|
||||||
elements: [
|
|
||||||
...(backupSize
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
tag: "markdown",
|
|
||||||
content: `**Backup Size:**\n${backupSize}`,
|
|
||||||
text_align: "left",
|
|
||||||
text_size: "normal_v2",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
{
|
|
||||||
tag: "markdown",
|
|
||||||
content: `**Date:**\n${format(date, "PP pp")}`,
|
|
||||||
text_align: "left",
|
|
||||||
text_size: "normal_v2",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
vertical_align: "top",
|
|
||||||
weight: 1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
...(type === "error" && truncatedErrorMessage
|
subtitle: {
|
||||||
? [
|
tag: "plain_text",
|
||||||
|
content: "",
|
||||||
|
},
|
||||||
|
template: type === "success" ? "green" : "red",
|
||||||
|
padding: "12px 12px 12px 12px",
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
direction: "vertical",
|
||||||
|
padding: "12px 12px 12px 12px",
|
||||||
|
elements: [
|
||||||
|
{
|
||||||
|
tag: "column_set",
|
||||||
|
columns: [
|
||||||
{
|
{
|
||||||
tag: "markdown",
|
tag: "column",
|
||||||
content: `**Error Message:**\n\`\`\`\n${truncatedErrorMessage}\n\`\`\``,
|
width: "weighted",
|
||||||
text_align: "left",
|
elements: [
|
||||||
text_size: "normal_v2",
|
{
|
||||||
|
tag: "markdown",
|
||||||
|
content:
|
||||||
|
"**Backup Type:**\nComplete Dokploy Instance",
|
||||||
|
text_align: "left",
|
||||||
|
text_size: "normal_v2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tag: "markdown",
|
||||||
|
content: `**Status:**\n${type === "success" ? "Successful" : "Failed"}`,
|
||||||
|
text_align: "left",
|
||||||
|
text_size: "normal_v2",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
vertical_align: "top",
|
||||||
|
weight: 1,
|
||||||
},
|
},
|
||||||
]
|
{
|
||||||
: []),
|
tag: "column",
|
||||||
],
|
width: "weighted",
|
||||||
|
elements: [
|
||||||
|
...(backupSize
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
tag: "markdown",
|
||||||
|
content: `**Backup Size:**\n${backupSize}`,
|
||||||
|
text_align: "left",
|
||||||
|
text_size: "normal_v2",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
{
|
||||||
|
tag: "markdown",
|
||||||
|
content: `**Date:**\n${format(date, "PP pp")}`,
|
||||||
|
text_align: "left",
|
||||||
|
text_size: "normal_v2",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
vertical_align: "top",
|
||||||
|
weight: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
...(type === "error" && truncatedErrorMessage
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
tag: "markdown",
|
||||||
|
content: `**Error Message:**\n\`\`\`\n${truncatedErrorMessage}\n\`\`\``,
|
||||||
|
text_align: "left",
|
||||||
|
text_size: "normal_v2",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (mattermost) {
|
||||||
|
const statusEmoji = type === "success" ? ":white_check_mark:" : ":x:";
|
||||||
|
const typeStatus = type === "success" ? "Successful" : "Failed";
|
||||||
|
await sendMattermostNotification(mattermost, {
|
||||||
|
text: `${statusEmoji} **Dokploy Backup ${typeStatus}**
|
||||||
|
|
||||||
|
**Backup Type:** Complete Dokploy Instance${backupSize ? `\n**Backup Size:** ${backupSize}` : ""}
|
||||||
|
**Date:** ${date.toLocaleString()}
|
||||||
|
**Status:** ${typeStatus}${type === "error" && errorMessage ? `\n\n**Error:**\n\`\`\`\n${errorMessage}\n\`\`\`` : ""}`,
|
||||||
|
channel: mattermost.channel,
|
||||||
|
username: mattermost.username || "Dokploy Bot",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (custom) {
|
||||||
|
await sendCustomNotification(custom, {
|
||||||
|
title: `Dokploy Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
|
message: `Dokploy instance backup ${type === "success" ? "completed successfully" : "failed"}`,
|
||||||
|
backupType: "Complete Dokploy Instance",
|
||||||
|
...(backupSize ? { backupSize } : {}),
|
||||||
|
...(type === "error" && errorMessage ? { errorMessage } : {}),
|
||||||
|
timestamp: date.toISOString(),
|
||||||
|
date: date.toLocaleString(),
|
||||||
|
status: type,
|
||||||
|
type: "dokploy-backup",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pushover) {
|
||||||
|
await sendPushoverNotification(
|
||||||
|
pushover,
|
||||||
|
`Dokploy Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
|
`Backup Type: Complete Dokploy Instance${backupSize ? `\nBackup Size: ${backupSize}` : ""}\nDate: ${date.toLocaleString()}${type === "error" && errorMessage ? `\nError: ${errorMessage}` : ""}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (teams) {
|
||||||
|
await sendTeamsNotification(teams, {
|
||||||
|
title: `${type === "success" ? "✅" : "❌"} Dokploy Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
|
facts: [
|
||||||
|
{ name: "Backup Type", value: "Complete Dokploy Instance" },
|
||||||
|
...(backupSize ? [{ name: "Backup Size", value: backupSize }] : []),
|
||||||
|
{ name: "Date", value: format(date, "PP pp") },
|
||||||
|
{
|
||||||
|
name: "Status",
|
||||||
|
value: type === "success" ? "Successful" : "Failed",
|
||||||
|
},
|
||||||
|
...(type === "error" && errorMessage
|
||||||
|
? [{ name: "Error Message", value: errorMessage }]
|
||||||
|
: []),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user