diff --git a/server/notification-providers/discord.js b/server/notification-providers/discord.js index 79768e3df..3ed509cea 100644 --- a/server/notification-providers/discord.js +++ b/server/notification-providers/discord.js @@ -11,6 +11,11 @@ class Discord extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { const okMsg = "Sent Successfully."; + // Discord Message Flags + // @see https://discord.com/developers/docs/resources/message#message-object-message-flags + // This message will not trigger push and desktop notifications + const SUPPRESS_NOTIFICATIONS_FLAG = 1 << 12; + try { let config = this.getAxiosConfigWithProxy({}); const discordDisplayName = notification.discordUsername || "Uptime Kuma"; @@ -41,6 +46,9 @@ class Discord extends NotificationProvider { if (notification.discordChannelType === "createNewForumPost") { discordtestdata.thread_name = notification.postName; } + if (notification.discordSuppressNotifications) { + discordtestdata.flags = SUPPRESS_NOTIFICATIONS_FLAG; + } await axios.post(webhookUrl.toString(), discordtestdata, config); return okMsg; } @@ -89,6 +97,9 @@ class Discord extends NotificationProvider { if (notification.discordPrefixMessage) { discorddowndata.content = notification.discordPrefixMessage; } + if (notification.discordSuppressNotifications) { + discorddowndata.flags = SUPPRESS_NOTIFICATIONS_FLAG; + } await axios.post(webhookUrl.toString(), discorddowndata, config); return okMsg; @@ -140,6 +151,9 @@ class Discord extends NotificationProvider { if (notification.discordPrefixMessage) { discordupdata.content = notification.discordPrefixMessage; } + if (notification.discordSuppressNotifications) { + discordupdata.flags = SUPPRESS_NOTIFICATIONS_FLAG; + } await axios.post(webhookUrl.toString(), discordupdata, config); return okMsg; diff --git a/src/components/notifications/Discord.vue b/src/components/notifications/Discord.vue index b65eb706a..6eff2a887 100644 --- a/src/components/notifications/Discord.vue +++ b/src/components/notifications/Discord.vue @@ -102,6 +102,24 @@ + +