diff --git a/apps/dokploy/server/api/routers/auth.ts b/apps/dokploy/server/api/routers/auth.ts index a1345cca3..b02ab617c 100644 --- a/apps/dokploy/server/api/routers/auth.ts +++ b/apps/dokploy/server/api/routers/auth.ts @@ -363,7 +363,7 @@ export const authRouter = createTRPCRouter({ Reset Password - + `, ); }), @@ -505,7 +505,7 @@ export const sendDiscordNotificationWelcome = async (newAdmin: Auth) => { webhookUrl: process.env.DISCORD_WEBHOOK_URL || "", }, { - title: " New User Registered", + title: "New User Registered", color: 0x00ff00, fields: [ { diff --git a/apps/dokploy/server/api/routers/notification.ts b/apps/dokploy/server/api/routers/notification.ts index 951d2a10d..ba226d457 100644 --- a/apps/dokploy/server/api/routers/notification.ts +++ b/apps/dokploy/server/api/routers/notification.ts @@ -187,11 +187,15 @@ export const notificationRouter = createTRPCRouter({ .input(apiTestDiscordConnection) .mutation(async ({ input }) => { try { + const decorate = (decoration: string, text: string) => + `${input.decoration ? decoration : ""} ${text}`.trim(); + await sendDiscordNotification(input, { - title: "> `๐Ÿคš` - Test Notification", - description: "> Hi, From Dokploy ๐Ÿ‘‹", + title: decorate(">", "`๐Ÿคš` - Test Notification"), + description: decorate(">", "Hi, From Dokploy ๐Ÿ‘‹"), color: 0xf3f7f4, }); + return true; } catch (error) { throw new TRPCError({ diff --git a/packages/server/src/utils/notifications/build-error.ts b/packages/server/src/utils/notifications/build-error.ts index f9286fc7f..695b37863 100644 --- a/packages/server/src/utils/notifications/build-error.ts +++ b/packages/server/src/utils/notifications/build-error.ts @@ -59,46 +59,49 @@ export const sendBuildErrorNotifications = async ({ } if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); + await sendDiscordNotification(discord, { - title: "> `โš ๏ธ` Build Failed", + title: decorate(">", "`โš ๏ธ` Build Failed"), color: 0xed4245, fields: [ { - name: "`๐Ÿ› ๏ธ` Project", + name: decorate("`๐Ÿ› ๏ธ`", "Project"), value: projectName, inline: true, }, { - name: "`โš™๏ธ` Application", + name: decorate("`โš™๏ธ`", "Application"), value: applicationName, inline: true, }, { - name: "`โ”` Type", + name: decorate("`โ”`", "Type"), value: applicationType, inline: true, }, { - name: "`๐Ÿ“…` Date", + name: decorate("`๐Ÿ“…`", "Date"), value: ``, inline: true, }, { - name: "`โŒš` Time", + name: decorate("`โŒš`", "Time"), value: ``, inline: true, }, { - name: "`โ“`Type", + name: decorate("`โ“`", "Type"), value: "Failed", inline: true, }, { - name: "`โš ๏ธ` Error Message", + name: decorate("`โš ๏ธ`", "Error Message"), value: `\`\`\`${errorMessage}\`\`\``, }, { - name: "`๐Ÿงท` Build Link", + name: decorate("`๐Ÿงท`", "Build Link"), value: `[Click here to access build link](${buildLink})`, }, ], @@ -114,15 +117,15 @@ export const sendBuildErrorNotifications = async ({ telegram, ` โš ๏ธ Build Failed - + Project: ${projectName} Application: ${applicationName} Type: ${applicationType} Time: ${date.toLocaleString()} - + Error:
${errorMessage}
- + Build Details: ${buildLink} `, ); diff --git a/packages/server/src/utils/notifications/build-success.ts b/packages/server/src/utils/notifications/build-success.ts index 97fe7e1cf..402b0cd2c 100644 --- a/packages/server/src/utils/notifications/build-success.ts +++ b/packages/server/src/utils/notifications/build-success.ts @@ -57,42 +57,45 @@ export const sendBuildSuccessNotifications = async ({ } if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); + await sendDiscordNotification(discord, { title: "> `โœ…` Build Success", color: 0x57f287, fields: [ { - name: "`๐Ÿ› ๏ธ` Project", + name: decorate("`๐Ÿ› ๏ธ`", "Project"), value: projectName, inline: true, }, { - name: "`โš™๏ธ` Application", + name: decorate("`โš™๏ธ`", "Application"), value: applicationName, inline: true, }, { - name: "`โ”` Application Type", + name: decorate("`โ”`", "Type"), value: applicationType, inline: true, }, { - name: "`๐Ÿ“…` Date", + name: decorate("`๐Ÿ“…`", "Date"), value: ``, inline: true, }, { - name: "`โŒš` Time", + name: decorate("`โŒš`", "Time"), value: ``, inline: true, }, { - name: "`โ“` Type", + name: decorate("`โ“`", "Type"), value: "Successful", inline: true, }, { - name: "`๐Ÿงท` Build Link", + name: decorate("`๐Ÿงท`", "Build Link"), value: `[Click here to access build link](${buildLink})`, }, ], @@ -108,12 +111,12 @@ export const sendBuildSuccessNotifications = async ({ telegram, ` โœ… Build Success - + Project: ${projectName} Application: ${applicationName} Type: ${applicationType} Time: ${date.toLocaleString()} - + Build Details: ${buildLink} `, ); diff --git a/packages/server/src/utils/notifications/database-backup.ts b/packages/server/src/utils/notifications/database-backup.ts index d2dccdafa..3aec6f3d3 100644 --- a/packages/server/src/utils/notifications/database-backup.ts +++ b/packages/server/src/utils/notifications/database-backup.ts @@ -62,40 +62,43 @@ export const sendDatabaseBackupNotifications = async ({ } if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); + await sendDiscordNotification(discord, { title: type === "success" - ? "> `โœ…` Database Backup Successful" - : "> `โŒ` Database Backup Failed", + ? decorate(">", "`โœ…` Database Backup Successful") + : decorate(">", "`โŒ` Database Backup Failed"), color: type === "success" ? 0x57f287 : 0xed4245, fields: [ { - name: "`๐Ÿ› ๏ธ` Project", + name: decorate("`๐Ÿ› ๏ธ`", "Project"), value: projectName, inline: true, }, { - name: "`โš™๏ธ` Application", + name: decorate("`โš™๏ธ`", "Application"), value: applicationName, inline: true, }, { - name: "`โ”` Database", + name: decorate("`โ”`", "Database"), value: databaseType, inline: true, }, { - name: "`๐Ÿ“…` Date", + name: decorate("`๐Ÿ“…`", "Date"), value: ``, inline: true, }, { - name: "`โŒš` Time", + name: decorate("`โŒš`", "Time"), value: ``, inline: true, }, { - name: "`โ“` Type", + name: decorate("`โ“`", "Type"), value: type .replace("error", "Failed") .replace("success", "Successful"), @@ -104,7 +107,7 @@ export const sendDatabaseBackupNotifications = async ({ ...(type === "error" && errorMessage ? [ { - name: "`โš ๏ธ` Error Message", + name: decorate("`โš ๏ธ`", "Error Message"), value: `\`\`\`${errorMessage}\`\`\``, }, ] @@ -121,12 +124,12 @@ export const sendDatabaseBackupNotifications = async ({ const statusEmoji = type === "success" ? "โœ…" : "โŒ"; const messageText = ` ${statusEmoji} Database Backup ${type === "success" ? "Successful" : "Failed"} - + Project: ${projectName} Application: ${applicationName} Type: ${databaseType} Time: ${date.toLocaleString()} - + Status: ${type === "success" ? "Successful" : "Failed"} ${type === "error" && errorMessage ? `Error: ${errorMessage}` : ""} `; diff --git a/packages/server/src/utils/notifications/docker-cleanup.ts b/packages/server/src/utils/notifications/docker-cleanup.ts index 515d1ddc4..c95c79067 100644 --- a/packages/server/src/utils/notifications/docker-cleanup.ts +++ b/packages/server/src/utils/notifications/docker-cleanup.ts @@ -45,27 +45,30 @@ export const sendDockerCleanupNotifications = async ( } if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); + await sendDiscordNotification(discord, { - title: "> `โœ…` Docker Cleanup", + title: decorate(">", "`โœ…` Docker Cleanup"), color: 0x57f287, fields: [ { - name: "`๐Ÿ“…` Date", + name: decorate("`๐Ÿ“…`", "Date"), value: ``, inline: true, }, { - name: "`โŒš` Time", + name: decorate("`โŒš`", "Time"), value: ``, inline: true, }, { - name: "`โ“` Type", + name: decorate("`โ“`", "Type"), value: "Successful", inline: true, }, { - name: "`๐Ÿ“œ` Message", + name: decorate("`๐Ÿ“œ`", "Message"), value: `\`\`\`${message}\`\`\``, }, ], diff --git a/packages/server/src/utils/notifications/dokploy-restart.ts b/packages/server/src/utils/notifications/dokploy-restart.ts index 883a3d1f1..16170349b 100644 --- a/packages/server/src/utils/notifications/dokploy-restart.ts +++ b/packages/server/src/utils/notifications/dokploy-restart.ts @@ -34,22 +34,25 @@ export const sendDokployRestartNotifications = async () => { } if (discord) { + const decorate = (decoration: string, text: string) => + `${discord.decoration ? decoration : ""} ${text}`.trim(); + await sendDiscordNotification(discord, { - title: "> `โœ…` Dokploy Server Restarted", + title: decorate(">", "`โœ…` Dokploy Server Restarted"), color: 0x57f287, fields: [ { - name: "`๐Ÿ“…` Date", + name: decorate("`๐Ÿ“…`", "Date"), value: ``, inline: true, }, { - name: "`โŒš` Time", + name: decorate("`โŒš`", "Time"), value: ``, inline: true, }, { - name: "`โ“` Type", + name: decorate("`โ“`", "Type"), value: "Successful", inline: true, },