mirror of
https://github.com/koichixD/uptime-kuma.git
synced 2026-09-04 17:23:21 +00:00
Feature/webhook get method support (#6194)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
@@ -12,6 +12,8 @@ class Webhook extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
const httpMethod = notification.httpMethod.toLowerCase() || "post";
|
||||
|
||||
let data = {
|
||||
heartbeat: heartbeatJSON,
|
||||
monitor: monitorJSON,
|
||||
@@ -21,7 +23,19 @@ class Webhook extends NotificationProvider {
|
||||
headers: {}
|
||||
};
|
||||
|
||||
if (notification.webhookContentType === "form-data") {
|
||||
if (httpMethod === "get") {
|
||||
config.params = {
|
||||
msg: msg
|
||||
};
|
||||
|
||||
if (heartbeatJSON) {
|
||||
config.params.heartbeat = JSON.stringify(heartbeatJSON);
|
||||
}
|
||||
|
||||
if (monitorJSON) {
|
||||
config.params.monitor = JSON.stringify(monitorJSON);
|
||||
}
|
||||
} else if (notification.webhookContentType === "form-data") {
|
||||
const formData = new FormData();
|
||||
formData.append("data", JSON.stringify(data));
|
||||
config.headers = formData.getHeaders();
|
||||
@@ -42,7 +56,13 @@ class Webhook extends NotificationProvider {
|
||||
}
|
||||
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
await axios.post(notification.webhookURL, data, config);
|
||||
|
||||
if (httpMethod === "get") {
|
||||
await axios.get(notification.webhookURL, config);
|
||||
} else {
|
||||
await axios.post(notification.webhookURL, data, config);
|
||||
}
|
||||
|
||||
return okMsg;
|
||||
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user