Feature/webhook get method support (#6194)

Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
aruj0
2025-10-27 21:19:05 +00:00
committed by GitHub
parent 38ec3bc432
commit 19c2bbd586
3 changed files with 45 additions and 2 deletions

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) {

View File

@@ -12,6 +12,21 @@
</div>
<div class="mb-3">
<label for="webhook-http-method" class="form-label">{{ $t("HTTP Method") }}</label>
<select
id="webhook-http-method"
v-model="$parent.notification.httpMethod"
class="form-select"
>
<option value="post">POST</option>
<option value="get">GET</option>
</select>
<div class="form-text">
{{ $parent.notification.httpMethod === 'get' ? $t("webhookGetMethodDesc") : $t("webhookPostMethodDesc") }}
</div>
</div>
<div v-if="$parent.notification.httpMethod === 'post'" class="mb-3">
<label for="webhook-request-body" class="form-label">{{ $t("Request Body") }}</label>
<select
id="webhook-request-body"
@@ -82,6 +97,11 @@ export default {
]);
}
},
mounted() {
if (typeof this.$parent.notification.httpMethod === "undefined") {
this.$parent.notification.httpMethod = "post";
}
},
};
</script>

View File

@@ -926,6 +926,9 @@
"noGroupMonitorMsg": "Not Available. Create a Group Monitor First.",
"Close": "Close",
"Request Body": "Request Body",
"HTTP Method": "HTTP Method",
"webhookPostMethodDesc": "POST is good for most modern HTTP servers.",
"webhookGetMethodDesc": "GET sends data as query parameters and does not allow configuring a body. Useful for triggering Uptime Kuma Push monitors.",
"wayToGetFlashDutyKey": "To integrate Uptime Kuma with Flashduty: Go to Channels > Select a channel > Integrations > Add a new integration, choose Uptime Kuma, and copy the Push URL.",
"FlashDuty Severity": "Severity",
"FlashDuty Push URL": "Push URL",