mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-20 18:45:56 +00:00
Add PostRequest Notification Provider
This commit is contained in:
parent
6899603eb7
commit
2a295dfe32
7 changed files with 55 additions and 3 deletions
30
server/notification-providers/postrequest.js
Normal file
30
server/notification-providers/postrequest.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
|
||||
class PostRequest extends NotificationProvider {
|
||||
name = "PostRequest";
|
||||
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
const url = notification.postrequestURL;
|
||||
|
||||
try {
|
||||
let config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + notification.postrequestToken,
|
||||
}
|
||||
};
|
||||
|
||||
let data = notification.postrequestBody;
|
||||
|
||||
let resp = await axios.post(url, data, config);
|
||||
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PostRequest;
|
|
@ -69,6 +69,7 @@ const Cellsynt = require("./notification-providers/cellsynt");
|
|||
const Onesender = require("./notification-providers/onesender");
|
||||
const Wpush = require("./notification-providers/wpush");
|
||||
const SendGrid = require("./notification-providers/send-grid");
|
||||
const PostRequest = require("./notification-providers/postrequest");
|
||||
|
||||
class Notification {
|
||||
|
||||
|
@ -154,7 +155,8 @@ class Notification {
|
|||
new GtxMessaging(),
|
||||
new Cellsynt(),
|
||||
new Wpush(),
|
||||
new SendGrid()
|
||||
new SendGrid(),
|
||||
new PostRequest()
|
||||
];
|
||||
for (let item of list) {
|
||||
if (! item.name) {
|
||||
|
@ -181,6 +183,7 @@ class Notification {
|
|||
if (this.providerList[notification.type]) {
|
||||
return this.providerList[notification.type].send(notification, msg, monitorJSON, heartbeatJSON);
|
||||
} else {
|
||||
console.log(notification.type);
|
||||
throw new Error("Notification type is not supported");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,8 @@ export default {
|
|||
"whapi": "WhatsApp (Whapi)",
|
||||
"gtxmessaging": "GtxMessaging",
|
||||
"Cellsynt": "Cellsynt",
|
||||
"SendGrid": "SendGrid"
|
||||
"SendGrid": "SendGrid",
|
||||
"PostRequest": "PostRequest",
|
||||
};
|
||||
|
||||
// Put notifications here if it's not supported in most regions or its documentation is not in English
|
||||
|
|
14
src/components/notifications/PostRequest.vue
Normal file
14
src/components/notifications/PostRequest.vue
Normal file
|
@ -0,0 +1,14 @@
|
|||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="postrequest-url" class="form-label">{{ $t("Post URL") }}</label>
|
||||
<input id="postrequest-url" v-model="$parent.notification.postrequestURL" type="text" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="postrequest-header" class="form-label">{{ $t("Bearer Token") }}</label>
|
||||
<input id="postrequest-header" v-model="$parent.notification.postrequestToken" type="text" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="postrequest-body" class="form-label">{{ $t("Body") }}</label>
|
||||
<input id="postrequest-body" v-model="$parent.notification.postrequestBody" type="text" class="form-control" required>
|
||||
</div>
|
||||
</template>
|
|
@ -67,6 +67,7 @@ import Cellsynt from "./Cellsynt.vue";
|
|||
import WPush from "./WPush.vue";
|
||||
import SIGNL4 from "./SIGNL4.vue";
|
||||
import SendGrid from "./SendGrid.vue";
|
||||
import PostRequest from "./PostRequest.vue";
|
||||
|
||||
/**
|
||||
* Manage all notification form.
|
||||
|
@ -142,6 +143,7 @@ const NotificationFormList = {
|
|||
"Cellsynt": Cellsynt,
|
||||
"WPush": WPush,
|
||||
"SendGrid": SendGrid,
|
||||
"PostRequest": PostRequest,
|
||||
};
|
||||
|
||||
export default NotificationFormList;
|
||||
|
|
|
@ -1098,5 +1098,6 @@
|
|||
"rabbitmqNodesDescription": "Gib die URL für die RabbitMQ-Verwaltungsknoten einschließlich Protokoll und Port ein. Beispiel: {0}",
|
||||
"rabbitmqNodesInvalid": "Benutze eine vollständig qualifizierte URL (beginnend mit 'http') für RabbitMQ-Knoten.",
|
||||
"rabbitmqHelpText": "Um den Monitor zu benutzen, musst du das Management Plugin in deinem RabbitMQ-Setup aktivieren. Weitere Informationen siehe {rabitmq_documentation}.",
|
||||
"aboutSlackUsername": "Ändert den Anzeigenamen des Absenders. Wenn du jemanden erwähnen möchtest, füge ihn stattdessen in den Namen ein."
|
||||
"aboutSlackUsername": "Ändert den Anzeigenamen des Absenders. Wenn du jemanden erwähnen möchtest, füge ihn stattdessen in den Namen ein.",
|
||||
"Bearer Token": "Bearer Token"
|
||||
}
|
||||
|
|
|
@ -550,6 +550,7 @@
|
|||
"Number": "Number",
|
||||
"Recipients": "Recipients",
|
||||
"Access Token": "Access Token",
|
||||
"Bearer Token": "Bearer Token",
|
||||
"Channel access token": "Channel access token",
|
||||
"Channel access token (Long-lived)": "Channel access token (Long-lived)",
|
||||
"Line Developers Console": "Line Developers Console",
|
||||
|
|
Loading…
Add table
Reference in a new issue