mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-24 02:15:59 +03:00
Include only nessacary data in webhook
This commit is contained in:
parent
47c72192e1
commit
e6a8a84278
2 changed files with 24 additions and 9 deletions
|
@ -42,7 +42,7 @@ class Monitor extends BeanModel {
|
||||||
/**
|
/**
|
||||||
* Return an object that ready to parse to JSON
|
* Return an object that ready to parse to JSON
|
||||||
*/
|
*/
|
||||||
async toJSON() {
|
async toJSON(includeSensitiveData = true) {
|
||||||
|
|
||||||
let notificationIDList = {};
|
let notificationIDList = {};
|
||||||
|
|
||||||
|
@ -56,15 +56,11 @@ class Monitor extends BeanModel {
|
||||||
|
|
||||||
const tags = await this.getTags();
|
const tags = await this.getTags();
|
||||||
|
|
||||||
return {
|
let data = {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
url: this.url,
|
url: this.url,
|
||||||
method: this.method,
|
method: this.method,
|
||||||
body: this.body,
|
|
||||||
headers: this.headers,
|
|
||||||
basic_auth_user: this.basic_auth_user,
|
|
||||||
basic_auth_pass: this.basic_auth_pass,
|
|
||||||
hostname: this.hostname,
|
hostname: this.hostname,
|
||||||
port: this.port,
|
port: this.port,
|
||||||
maxretries: this.maxretries,
|
maxretries: this.maxretries,
|
||||||
|
@ -82,11 +78,23 @@ class Monitor extends BeanModel {
|
||||||
dns_resolve_type: this.dns_resolve_type,
|
dns_resolve_type: this.dns_resolve_type,
|
||||||
dns_resolve_server: this.dns_resolve_server,
|
dns_resolve_server: this.dns_resolve_server,
|
||||||
dns_last_result: this.dns_last_result,
|
dns_last_result: this.dns_last_result,
|
||||||
pushToken: this.pushToken,
|
|
||||||
proxyId: this.proxy_id,
|
proxyId: this.proxy_id,
|
||||||
notificationIDList,
|
notificationIDList,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (includeSensitiveData) {
|
||||||
|
data = {
|
||||||
|
...data,
|
||||||
|
headers: this.headers,
|
||||||
|
body: this.body,
|
||||||
|
basic_auth_user: this.basic_auth_user,
|
||||||
|
basic_auth_pass: this.basic_auth_pass,
|
||||||
|
pushToken: this.pushToken,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTags() {
|
async getTags() {
|
||||||
|
@ -727,7 +735,7 @@ class Monitor extends BeanModel {
|
||||||
|
|
||||||
for (let notification of notificationList) {
|
for (let notification of notificationList) {
|
||||||
try {
|
try {
|
||||||
await Notification.send(JSON.parse(notification.config), msg, await monitor.toJSON(), bean.toJSON());
|
await Notification.send(JSON.parse(notification.config), msg, await monitor.toJSON(false), bean.toJSON());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error("monitor", "Cannot send notification to " + notification.name);
|
log.error("monitor", "Cannot send notification to " + notification.name);
|
||||||
log.error("monitor", e);
|
log.error("monitor", e);
|
||||||
|
|
|
@ -11,7 +11,7 @@ if (nodeVersion < requiredVersion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = require("args-parser")(process.argv);
|
const args = require("args-parser")(process.argv);
|
||||||
const { sleep, log, getRandomInt, genSecret, debug } = require("../src/util");
|
const { sleep, log, getRandomInt, genSecret, debug, isDev } = require("../src/util");
|
||||||
const config = require("./config");
|
const config = require("./config");
|
||||||
|
|
||||||
log.info("server", "Welcome to Uptime Kuma");
|
log.info("server", "Welcome to Uptime Kuma");
|
||||||
|
@ -235,6 +235,13 @@ try {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (isDev) {
|
||||||
|
app.post("/test-webhook", async (request, response) => {
|
||||||
|
log.debug("test", request.body);
|
||||||
|
response.send("OK");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Robots.txt
|
// Robots.txt
|
||||||
app.get("/robots.txt", async (_request, response) => {
|
app.get("/robots.txt", async (_request, response) => {
|
||||||
let txt = "User-agent: *\nDisallow:";
|
let txt = "User-agent: *\nDisallow:";
|
||||||
|
|
Loading…
Reference in a new issue