mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-09 23:24:07 -08:00
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)
This commit is contained in:
parent
fd10897988
commit
00f733d352
|
@ -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} <!channel>`
|
||||
: 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",
|
||||
|
|
|
@ -24,5 +24,11 @@
|
|||
<a href="https://www.webfx.com/tools/emoji-cheat-sheet/" target="_blank">https://www.webfx.com/tools/emoji-cheat-sheet/</a>
|
||||
</i18n-t>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch">
|
||||
<input id="slack-channel-mention" v-model="$parent.notification.slackchannelmention" type="checkbox" class="form-check-input">
|
||||
<label for="slack-channel-mention" class="form-label">{{ $t("Mention Channel") }}</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
|
Loading…
Reference in a new issue