Feature/webhook get method support (#6194)

Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
aruj0
2025-10-27 22:19:05 +01:00
committed by GitHub
co-authored by Frank Elsinga
parent 38ec3bc432
commit 19c2bbd586
3 changed files with 45 additions and 2 deletions
+22 -2
View File
@@ -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) {