From a235815a13c494b07ca63b9f4571340a98f0d684 Mon Sep 17 00:00:00 2001 From: 190km Date: Sun, 1 Dec 2024 04:09:19 +0100 Subject: [PATCH] style: improved discord webhooks notifications --- .../server/api/routers/notification.ts | 5 ++- .../src/utils/notifications/build-error.ts | 22 +++++------ .../src/utils/notifications/build-success.ts | 18 ++++----- .../utils/notifications/database-backup.ts | 39 ++++++++++--------- .../src/utils/notifications/docker-cleanup.ts | 8 ++-- .../utils/notifications/dokploy-restart.ts | 8 ++-- 6 files changed, 51 insertions(+), 49 deletions(-) diff --git a/apps/dokploy/server/api/routers/notification.ts b/apps/dokploy/server/api/routers/notification.ts index 170b7bf2..504e3320 100644 --- a/apps/dokploy/server/api/routers/notification.ts +++ b/apps/dokploy/server/api/routers/notification.ts @@ -188,8 +188,9 @@ export const notificationRouter = createTRPCRouter({ .mutation(async ({ input }) => { try { await sendDiscordNotification(input, { - title: "Test Notification", - description: "Hi, From Dokploy 👋", + title: "> `🤚` - Test Notification", + description: "> Hi, From Dokploy 👋", + color: 0xf3f7f4 }); return true; } catch (error) { diff --git a/packages/server/src/utils/notifications/build-error.ts b/packages/server/src/utils/notifications/build-error.ts index 9fcb0641..a8a7bf25 100644 --- a/packages/server/src/utils/notifications/build-error.ts +++ b/packages/server/src/utils/notifications/build-error.ts @@ -59,30 +59,30 @@ export const sendBuildErrorNotifications = async ({ if (discord) { await sendDiscordNotification(discord, { - title: "⚠️ Build Failed", - color: 0xff0000, + title: "> `⚠️` - Build Failed", + color: 0xed4245, fields: [ { - name: "Project", - value: projectName, + name: "`🛠️`・Project", + value: `\`\`\`${projectName}\`\`\``, inline: true, }, { - name: "Application", - value: applicationName, + name: "`⚙️`・Application", + value: `\`\`\`${applicationName}\`\`\``, inline: true, }, { - name: "Type", - value: applicationType, + name: "`❔`・Type", + value: `\`\`\`${applicationType}\`\`\``, inline: true, }, { - name: "Error", - value: errorMessage, + name: "`⚠️`・Error Message", + value: `\`\`\`${errorMessage}\`\`\``, }, { - name: "Build Link", + name: "`🧷`・Build Link", value: buildLink, }, ], diff --git a/packages/server/src/utils/notifications/build-success.ts b/packages/server/src/utils/notifications/build-success.ts index 9210eca2..4475bd44 100644 --- a/packages/server/src/utils/notifications/build-success.ts +++ b/packages/server/src/utils/notifications/build-success.ts @@ -57,26 +57,26 @@ export const sendBuildSuccessNotifications = async ({ if (discord) { await sendDiscordNotification(discord, { - title: "✅ Build Success", - color: 0x00ff00, + title: "> `✅` - Build Success", + color: 0x57f287, fields: [ { - name: "Project", - value: projectName, + name: "`🛠️`・Project", + value: `\`\`\`${projectName}\`\`\``, inline: true, }, { - name: "Application", - value: applicationName, + name: "`⚙️`・Application", + value: `\`\`\`${applicationName}\`\`\``, inline: true, }, { - name: "Type", - value: applicationType, + name: "`❔`・Type", + value: `\`\`\`${applicationType}\`\`\``, inline: true, }, { - name: "Build Link", + name: "`🧷`・Build Link", value: buildLink, }, ], diff --git a/packages/server/src/utils/notifications/database-backup.ts b/packages/server/src/utils/notifications/database-backup.ts index c97afa03..63a842ab 100644 --- a/packages/server/src/utils/notifications/database-backup.ts +++ b/packages/server/src/utils/notifications/database-backup.ts @@ -64,39 +64,40 @@ export const sendDatabaseBackupNotifications = async ({ await sendDiscordNotification(discord, { title: type === "success" - ? "✅ Database Backup Successful" - : "❌ Database Backup Failed", - color: type === "success" ? 0x00ff00 : 0xff0000, + ? "> `✅` - Database Backup Successful" + : "> `❌` - Database Backup Failed", + color: type === "success" ? 0x57f287 : 0xed4245, fields: [ { - name: "Project", - value: projectName, + name: "`🛠️`・Project", + value: `\`\`\`${projectName}\`\`\``, + inline: false, + }, + { + name: "`⚙️`・Application", + value: `\`\`\`${applicationName}\`\`\``, inline: true, }, { - name: "Application", - value: applicationName, + name: "`❔`・Type", + value: `\`\`\`${databaseType}\`\`\``, inline: true, }, { - name: "Type", - value: databaseType, - inline: true, + name: "`📅`・Time", + value: `\`\`\`${date.toLocaleString()}\`\`\``, + inline: false, }, { - name: "Time", - value: date.toLocaleString(), - inline: true, - }, - { - name: "Type", - value: type, + name: "`❔`・Type", + value: `\`\`\`${type}\`\`\``, + inline: false, }, ...(type === "error" && errorMessage ? [ { - name: "Error Message", - value: errorMessage, + name: "`⚠️`・Error Message", + value: `\`\`\`${errorMessage}\`\`\``, }, ] : []), diff --git a/packages/server/src/utils/notifications/docker-cleanup.ts b/packages/server/src/utils/notifications/docker-cleanup.ts index a2e09139..68c3f119 100644 --- a/packages/server/src/utils/notifications/docker-cleanup.ts +++ b/packages/server/src/utils/notifications/docker-cleanup.ts @@ -45,12 +45,12 @@ export const sendDockerCleanupNotifications = async ( if (discord) { await sendDiscordNotification(discord, { - title: "✅ Docker Cleanup", - color: 0x00ff00, + title: "> `✅` - Docker Cleanup", + color: 0x57f287, fields: [ { - name: "Message", - value: message, + name: "`📜`・Message", + value: `\`\`\`${message}\`\`\``, }, ], timestamp: date.toISOString(), diff --git a/packages/server/src/utils/notifications/dokploy-restart.ts b/packages/server/src/utils/notifications/dokploy-restart.ts index 33bc32f0..451044f4 100644 --- a/packages/server/src/utils/notifications/dokploy-restart.ts +++ b/packages/server/src/utils/notifications/dokploy-restart.ts @@ -34,12 +34,12 @@ export const sendDokployRestartNotifications = async () => { if (discord) { await sendDiscordNotification(discord, { - title: "✅ Dokploy Server Restarted", - color: 0x00ff00, + title: "> `✅` - Dokploy Server Restarted", + color: 0x57f287, fields: [ { - name: "Time", - value: date.toLocaleString(), + name: "`📅`・Time", + value: `\`\`\`${date.toLocaleString()}\`\`\``, inline: true, }, ],