From fd10897988b2e779d929f346ef63417014258894 Mon Sep 17 00:00:00 2001 From: duane Date: Mon, 17 Apr 2023 12:46:52 -0500 Subject: [PATCH 1/6] Adds translation for English Slack channel mention label --- src/lang/en.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lang/en.json b/src/lang/en.json index f33a7de37..3e95a1a36 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -624,6 +624,7 @@ "matrixDesc1": "You can find the internal room ID by looking in the advanced section of the room settings in your Matrix client. It should look like !QMdRCpUIfLwsfjxye6:home.server.", "matrixDesc2": "It is highly recommended you create a new user and do not use your own Matrix user's access token as it will allow full access to your account and all the rooms you joined. Instead, create a new user and only invite it to the room that you want to receive the notification in. You can get the access token by running {0}", "Channel Name": "Channel Name", + "Mention Channel": "Mention Channel", "Uptime Kuma URL": "Uptime Kuma URL", "Icon Emoji": "Icon Emoji", "signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!", From 00f733d35280dab78d124b52abdc4edd7cc0fddc Mon Sep 17 00:00:00 2001 From: duane Date: Mon, 17 Apr 2023 12:49:15 -0500 Subject: [PATCH 2/6] Adds ability to notify channel when Slack webhook triggered - Adds field to toggle channel mentions on/off for Slack integration - Adds special mention for @channel when enabled Reference: [Slack docs](https://api.slack.com/reference/surfaces/formatting#special-mentions) --- server/notification-providers/slack.js | 12 ++++++++---- src/components/notifications/Slack.vue | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index da89f0f7a..f4a72b03e 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -27,10 +27,14 @@ class Slack extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; + const finalMsg = notification.slackchannelmention + ? `${msg} ` + : msg; + try { if (heartbeatJSON == null) { let data = { - "text": msg, + "text": finalMsg, "channel": notification.slackchannel, "username": notification.slackusername, "icon_emoji": notification.slackiconemo, @@ -42,7 +46,7 @@ class Slack extends NotificationProvider { const time = heartbeatJSON["time"]; const textMsg = "Uptime Kuma Alert"; let data = { - "text": `${textMsg}\n${msg}`, + "text": `${textMsg}\n${finalMsg}`, "channel": notification.slackchannel, "username": notification.slackusername, "icon_emoji": notification.slackiconemo, @@ -54,14 +58,14 @@ class Slack extends NotificationProvider { "type": "header", "text": { "type": "plain_text", - "text": "Uptime Kuma Alert", + "text": textMsg, }, }, { "type": "section", "fields": [{ "type": "mrkdwn", - "text": "*Message*\n" + msg, + "text": "*Message*\n" + finalMsg, }, { "type": "mrkdwn", diff --git a/src/components/notifications/Slack.vue b/src/components/notifications/Slack.vue index 6d220caad..34ef5feb8 100644 --- a/src/components/notifications/Slack.vue +++ b/src/components/notifications/Slack.vue @@ -24,5 +24,11 @@ https://www.webfx.com/tools/emoji-cheat-sheet/ + +
+ + +
+ From 9825b33ef35807f7e6c1dba9c6a2ab1c3f8d3e05 Mon Sep 17 00:00:00 2001 From: duane Date: Mon, 17 Apr 2023 13:05:41 -0500 Subject: [PATCH 3/6] Fixes eslint warnings for Slack notification modal --- src/components/notifications/Slack.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/notifications/Slack.vue b/src/components/notifications/Slack.vue index 34ef5feb8..a9b05e683 100644 --- a/src/components/notifications/Slack.vue +++ b/src/components/notifications/Slack.vue @@ -29,6 +29,5 @@ - From 5200e10aabf562a2080c60a77b111d20842213c1 Mon Sep 17 00:00:00 2001 From: duane Date: Tue, 23 May 2023 10:29:18 -0500 Subject: [PATCH 4/6] Removes ternary operator for Slack channel mention --- server/notification-providers/slack.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index f4a72b03e..27bf259af 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -27,14 +27,15 @@ class Slack extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; - const finalMsg = notification.slackchannelmention - ? `${msg} ` - : msg; + + if (notification.slackchannelmention) { + msg += " "; + } try { if (heartbeatJSON == null) { let data = { - "text": finalMsg, + "text": msg, "channel": notification.slackchannel, "username": notification.slackusername, "icon_emoji": notification.slackiconemo, @@ -46,7 +47,7 @@ class Slack extends NotificationProvider { const time = heartbeatJSON["time"]; const textMsg = "Uptime Kuma Alert"; let data = { - "text": `${textMsg}\n${finalMsg}`, + "text": `${textMsg}\n${msg}`, "channel": notification.slackchannel, "username": notification.slackusername, "icon_emoji": notification.slackiconemo, @@ -65,7 +66,7 @@ class Slack extends NotificationProvider { "type": "section", "fields": [{ "type": "mrkdwn", - "text": "*Message*\n" + finalMsg, + "text": "*Message*\n" + msg, }, { "type": "mrkdwn", From 9a8bea576177bccdc10ea2d70b76610f6aa37e19 Mon Sep 17 00:00:00 2001 From: duane Date: Thu, 1 Jun 2023 08:23:13 -0500 Subject: [PATCH 5/6] Changes 'Mention Channel' -> 'Notify Channel' - Updates variable names - Updates any Slack mention references --- server/notification-providers/slack.js | 2 +- src/components/notifications/Slack.vue | 4 ++-- src/lang/en.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index b3986b00f..41c2bd02c 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -28,7 +28,7 @@ class Slack extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; - if (notification.slackchannelmention) { + if (notification.slackchannelnotify) { msg += " "; } diff --git a/src/components/notifications/Slack.vue b/src/components/notifications/Slack.vue index a9b05e683..e99fc31e3 100644 --- a/src/components/notifications/Slack.vue +++ b/src/components/notifications/Slack.vue @@ -26,8 +26,8 @@
- - + +
diff --git a/src/lang/en.json b/src/lang/en.json index 5ebbef133..10dca0811 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -625,7 +625,7 @@ "matrixDesc1": "You can find the internal room ID by looking in the advanced section of the room settings in your Matrix client. It should look like !QMdRCpUIfLwsfjxye6:home.server.", "matrixDesc2": "It is highly recommended you create a new user and do not use your own Matrix user's access token as it will allow full access to your account and all the rooms you joined. Instead, create a new user and only invite it to the room that you want to receive the notification in. You can get the access token by running {0}", "Channel Name": "Channel Name", - "Mention Channel": "Mention Channel", + "Notify Channel": "Notify Channel", "Uptime Kuma URL": "Uptime Kuma URL", "Icon Emoji": "Icon Emoji", "signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!", From 1fa8c0f9fef5ab94c80fc33e46133910538a0b2d Mon Sep 17 00:00:00 2001 From: duane Date: Thu, 1 Jun 2023 08:40:26 -0500 Subject: [PATCH 6/6] Adds help text for `Notify Channel` option --- src/components/notifications/Slack.vue | 3 +++ src/lang/en.json | 1 + 2 files changed, 4 insertions(+) diff --git a/src/components/notifications/Slack.vue b/src/components/notifications/Slack.vue index e99fc31e3..dead709ce 100644 --- a/src/components/notifications/Slack.vue +++ b/src/components/notifications/Slack.vue @@ -29,5 +29,8 @@ +
+ {{ $t("aboutNotifyChannel") }} +
diff --git a/src/lang/en.json b/src/lang/en.json index 10dca0811..6546f0a02 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -626,6 +626,7 @@ "matrixDesc2": "It is highly recommended you create a new user and do not use your own Matrix user's access token as it will allow full access to your account and all the rooms you joined. Instead, create a new user and only invite it to the room that you want to receive the notification in. You can get the access token by running {0}", "Channel Name": "Channel Name", "Notify Channel": "Notify Channel", + "aboutNotifyChannel": "Notify channel will trigger a desktop or mobile notification for all members of the channel, whether their availability is set to active or away.", "Uptime Kuma URL": "Uptime Kuma URL", "Icon Emoji": "Icon Emoji", "signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!",