Browse Source
Merge remote-tracking branch 'NiNiyas/slack-webhook'
# Conflicts:
# README.md
# dockerfile
# package.json
# server/notification.js
# src/components/NotificationDialog.vue
pull/154/head^2
Philipp Dormann
4 years ago
No known key found for this signature in database
GPG Key ID: 3BB9ADD52DCA4314
2 changed files with
110 additions and
9 deletions
-
server/notification.js
-
src/components/NotificationDialog.vue
|
@ -35,6 +35,93 @@ class Notification { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else if (notification.type === "slack") { |
|
|
|
|
|
try { |
|
|
|
|
|
if (heartbeatJSON == null) { |
|
|
|
|
|
let data = { |
|
|
|
|
|
"blocks": [{ |
|
|
|
|
|
"type": "header", |
|
|
|
|
|
"text": { |
|
|
|
|
|
"type": "plain_text", |
|
|
|
|
|
"text": "Uptime Kuma - Slack Testing" |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "section", |
|
|
|
|
|
"fields": [{ |
|
|
|
|
|
"type": "mrkdwn", |
|
|
|
|
|
"text": "*Message*\nSlack Testing" |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "mrkdwn", |
|
|
|
|
|
"text": "*Time (UTC)*\nSlack Testing" |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "actions", |
|
|
|
|
|
"elements": [ |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "button", |
|
|
|
|
|
"text": { |
|
|
|
|
|
"type": "plain_text", |
|
|
|
|
|
"text": "Visit Uptime Kuma", |
|
|
|
|
|
}, |
|
|
|
|
|
"value": "Uptime-Kuma", |
|
|
|
|
|
"url": notification.slackbutton |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
} |
|
|
|
|
|
let res = await axios.post(notification.slackwebhookURL, data) |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const time = heartbeatJSON["time"]; |
|
|
|
|
|
let data = { |
|
|
|
|
|
"blocks": [{ |
|
|
|
|
|
"type": "header", |
|
|
|
|
|
"text": { |
|
|
|
|
|
"type": "plain_text", |
|
|
|
|
|
"text": "Uptime Kuma Alert" |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "section", |
|
|
|
|
|
"fields": [{ |
|
|
|
|
|
"type": "mrkdwn", |
|
|
|
|
|
"text": '*Message*\n' + msg |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "mrkdwn", |
|
|
|
|
|
"text": "*Time (UTC)*\n" + time |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "actions", |
|
|
|
|
|
"elements": [ |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "button", |
|
|
|
|
|
"text": { |
|
|
|
|
|
"type": "plain_text", |
|
|
|
|
|
"text": "Visit Uptime Kuma", |
|
|
|
|
|
}, |
|
|
|
|
|
"value": "Uptime-Kuma", |
|
|
|
|
|
"url": notification.slackbutton |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
} |
|
|
|
|
|
let res = await axios.post(notification.slackwebhookURL, data) |
|
|
|
|
|
return true; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.log(error) |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} else if (notification.type === "webhook") { |
|
|
} else if (notification.type === "webhook") { |
|
|
try { |
|
|
try { |
|
|
|
|
|
|
|
|
|
@ -19,6 +19,7 @@ |
|
|
<option value="discord">Discord</option> |
|
|
<option value="discord">Discord</option> |
|
|
<option value="signal">Signal</option> |
|
|
<option value="signal">Signal</option> |
|
|
<option value="gotify">Gotify</option> |
|
|
<option value="gotify">Gotify</option> |
|
|
|
|
|
<option value="slack">Slack</option> |
|
|
</select> |
|
|
</select> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
@ -183,6 +184,19 @@ |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
<template v-if="notification.type === 'slack'"> |
|
|
|
|
|
<div class="mb-3"> |
|
|
|
|
|
<label for="slack-webhook-url" class="form-label">Slack Webhook URL</label> |
|
|
|
|
|
<input type="text" class="form-control" id="slack-webhook-url" required v-model="notification.slackwebhookURL" autocomplete="false"> |
|
|
|
|
|
<label for="gotify-server-url" class="form-label">Uptime Kuma URL</label> |
|
|
|
|
|
<div class="input-group mb-3"> |
|
|
|
|
|
<input type="text" class="form-control" id="slack-button" required v-model="notification.slackbutton" autocomplete="false"> |
|
|
|
|
|
</div> |
|
|
|
|
|
<p style="margin-top: 8px;"> |
|
|
|
|
|
More info on: <a href="https://api.slack.com/messaging/webhooks" target="_blank">https://api.slack.com/messaging/webhooks</a> |
|
|
|
|
|
</p> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
<div class="modal-footer"> |
|
|
<div class="modal-footer"> |
|
|