parent
8a432ac937
commit
c697a47c9a
@ -0,0 +1,52 @@
|
||||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
const { UP } = require("../../src/util");
|
||||
|
||||
class Pumble extends NotificationProvider {
|
||||
name = "pumble";
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
let webhookUrl = notification.pumblewebhookURL;
|
||||
|
||||
try {
|
||||
if (heartbeatJSON === null && monitorJSON === null) {
|
||||
// Test message
|
||||
let data = {
|
||||
"text": "Uptime Kuma Alert",
|
||||
"attachments": [
|
||||
{
|
||||
"title": "Test Alert",
|
||||
"text": msg,
|
||||
"color": "#5BDD8B"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
await axios.post(webhookUrl, data);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
let data = {
|
||||
"text": "Uptime Kuma Alert",
|
||||
"attachments": [
|
||||
{
|
||||
"title": `${monitorJSON["name"]} is ${heartbeatJSON["status"] === UP ? "up" : "down"}`,
|
||||
"text": heartbeatJSON["msg"],
|
||||
"color": (heartbeatJSON["status"] === UP ? "#5BDD8B" : "#DC3645"),
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
await axios.post(webhookUrl, data);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Pumble;
|
@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="pumble-webhook-url" class="form-label mb-2">{{ $t("Webhook URL") }}</label><span style="color: red;"><sup>*</sup></span>
|
||||
<input id="pumble-webhook-url" v-model="$parent.notification.pumblewebhookURL" type="text" class="form-control" required>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
</script>
|
Loading…
Reference in new issue