Merge pull request #3203 from CommanderStorm/applied_timezone_formatting

chore: Made sure that every notification provider uses `timezone`/`localTime`
pull/3222/head
Louis Lam 2 years ago committed by GitHub
commit 343a1d3344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -59,8 +59,8 @@ class Discord extends NotificationProvider {
value: monitorJSON["type"] === "push" ? "Heartbeat" : address, value: monitorJSON["type"] === "push" ? "Heartbeat" : address,
}, },
{ {
name: "Time (UTC)", name: `Time (${heartbeatJSON["timezone"]})`,
value: heartbeatJSON["time"], value: heartbeatJSON["localDateTime"],
}, },
{ {
name: "Error", name: "Error",
@ -94,8 +94,8 @@ class Discord extends NotificationProvider {
value: monitorJSON["type"] === "push" ? "Heartbeat" : address, value: monitorJSON["type"] === "push" ? "Heartbeat" : address,
}, },
{ {
name: "Time (UTC)", name: `Time (${heartbeatJSON["timezone"]})`,
value: heartbeatJSON["time"], value: heartbeatJSON["localDateTime"],
}, },
{ {
name: "Ping", name: "Ping",

@ -35,8 +35,7 @@ class Feishu extends NotificationProvider {
text: text:
"[Down] " + "[Down] " +
heartbeatJSON["msg"] + heartbeatJSON["msg"] +
"\nTime (UTC): " + `\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
heartbeatJSON["time"],
}, },
], ],
], ],
@ -62,8 +61,7 @@ class Feishu extends NotificationProvider {
text: text:
"[Up] " + "[Up] " +
heartbeatJSON["msg"] + heartbeatJSON["msg"] +
"\nTime (UTC): " + `\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
heartbeatJSON["time"],
}, },
], ],
], ],

@ -33,7 +33,10 @@ class Line extends NotificationProvider {
"messages": [ "messages": [
{ {
"type": "text", "type": "text",
"text": "UptimeKuma Alert: [🔴 Down]\n" + "Name: " + monitorJSON["name"] + " \n" + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"] "text": "UptimeKuma Alert: [🔴 Down]\n" +
"Name: " + monitorJSON["name"] + " \n" +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
} }
] ]
}; };
@ -44,7 +47,10 @@ class Line extends NotificationProvider {
"messages": [ "messages": [
{ {
"type": "text", "type": "text",
"text": "UptimeKuma Alert: [✅ Up]\n" + "Name: " + monitorJSON["name"] + " \n" + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"] "text": "UptimeKuma Alert: [✅ Up]\n" +
"Name: " + monitorJSON["name"] + " \n" +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
} }
] ]
}; };

@ -24,12 +24,18 @@ class LineNotify extends NotificationProvider {
await axios.post(lineAPIUrl, qs.stringify(testMessage), config); await axios.post(lineAPIUrl, qs.stringify(testMessage), config);
} else if (heartbeatJSON["status"] === DOWN) { } else if (heartbeatJSON["status"] === DOWN) {
let downMessage = { let downMessage = {
"message": "\n[🔴 Down]\n" + "Name: " + monitorJSON["name"] + " \n" + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"] "message": "\n[🔴 Down]\n" +
"Name: " + monitorJSON["name"] + " \n" +
heartbeatJSON["msg"] + "\n" +
`Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
}; };
await axios.post(lineAPIUrl, qs.stringify(downMessage), config); await axios.post(lineAPIUrl, qs.stringify(downMessage), config);
} else if (heartbeatJSON["status"] === UP) { } else if (heartbeatJSON["status"] === UP) {
let upMessage = { let upMessage = {
"message": "\n[✅ Up]\n" + "Name: " + monitorJSON["name"] + " \n" + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"] "message": "\n[✅ Up]\n" +
"Name: " + monitorJSON["name"] + " \n" +
heartbeatJSON["msg"] + "\n" +
`Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
}; };
await axios.post(lineAPIUrl, qs.stringify(upMessage), config); await axios.post(lineAPIUrl, qs.stringify(upMessage), config);
} }

@ -28,7 +28,9 @@ class LunaSea extends NotificationProvider {
if (heartbeatJSON["status"] === DOWN) { if (heartbeatJSON["status"] === DOWN) {
let downdata = { let downdata = {
"title": "UptimeKuma Alert: " + monitorJSON["name"], "title": "UptimeKuma Alert: " + monitorJSON["name"],
"body": "[🔴 Down] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"], "body": "[🔴 Down] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
}; };
await axios.post(lunaseaurl, downdata); await axios.post(lunaseaurl, downdata);
return okMsg; return okMsg;
@ -37,7 +39,9 @@ class LunaSea extends NotificationProvider {
if (heartbeatJSON["status"] === UP) { if (heartbeatJSON["status"] === UP) {
let updata = { let updata = {
"title": "UptimeKuma Alert: " + monitorJSON["name"], "title": "UptimeKuma Alert: " + monitorJSON["name"],
"body": "[✅ Up] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"], "body": "[✅ Up] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
}; };
await axios.post(lunaseaurl, updata); await axios.post(lunaseaurl, updata);
return okMsg; return okMsg;

@ -88,8 +88,8 @@ class Mattermost extends NotificationProvider {
statusField, statusField,
{ {
short: true, short: true,
title: "Time (UTC)", title: `Time (${heartbeatJSON["timezone"]})`,
value: heartbeatJSON.time, value: heartbeatJSON.localDateTime,
}, },
], ],
}, },

@ -29,14 +29,18 @@ class Pushbullet extends NotificationProvider {
let downData = { let downData = {
"type": "note", "type": "note",
"title": "UptimeKuma Alert: " + monitorJSON["name"], "title": "UptimeKuma Alert: " + monitorJSON["name"],
"body": "[🔴 Down] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"], "body": "[🔴 Down] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
}; };
await axios.post(pushbulletUrl, downData, config); await axios.post(pushbulletUrl, downData, config);
} else if (heartbeatJSON["status"] === UP) { } else if (heartbeatJSON["status"] === UP) {
let upData = { let upData = {
"type": "note", "type": "note",
"title": "UptimeKuma Alert: " + monitorJSON["name"], "title": "UptimeKuma Alert: " + monitorJSON["name"],
"body": "[✅ Up] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"], "body": "[✅ Up] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
}; };
await axios.post(pushbulletUrl, upData, config); await axios.post(pushbulletUrl, upData, config);
} }

@ -33,7 +33,7 @@ class Pushover extends NotificationProvider {
await axios.post(pushoverlink, data); await axios.post(pushoverlink, data);
return okMsg; return okMsg;
} else { } else {
data.message += "\n<b>Time (UTC)</b>:" + heartbeatJSON["time"]; data.message += `\n<b>Time (${heartbeatJSON["timezone"]})</b>:${heartbeatJSON["localDateTime"]}`;
await axios.post(pushoverlink, data); await axios.post(pushoverlink, data);
return okMsg; return okMsg;
} }

@ -22,8 +22,6 @@ class RocketChat extends NotificationProvider {
return okMsg; return okMsg;
} }
const time = heartbeatJSON["time"];
let data = { let data = {
"text": "Uptime Kuma Alert", "text": "Uptime Kuma Alert",
"channel": notification.rocketchannel, "channel": notification.rocketchannel,
@ -31,7 +29,7 @@ class RocketChat extends NotificationProvider {
"icon_emoji": notification.rocketiconemo, "icon_emoji": notification.rocketiconemo,
"attachments": [ "attachments": [
{ {
"title": "Uptime Kuma Alert *Time (UTC)*\n" + time, "title": `Uptime Kuma Alert *Time (${heartbeatJSON["timezone"]})*\n${heartbeatJSON["localDateTime"]}`,
"text": "*Message*\n" + msg, "text": "*Message*\n" + msg,
} }
] ]

@ -39,7 +39,6 @@ class Slack extends NotificationProvider {
return okMsg; return okMsg;
} }
const time = heartbeatJSON["time"];
const textMsg = "Uptime Kuma Alert"; const textMsg = "Uptime Kuma Alert";
let data = { let data = {
"text": `${textMsg}\n${msg}`, "text": `${textMsg}\n${msg}`,
@ -65,7 +64,7 @@ class Slack extends NotificationProvider {
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Time (UTC)*\n" + time, "text": `*Time (${heartbeatJSON["timezone"]})*\n${heartbeatJSON["localDateTime"]}`,
}], }],
} }
], ],

@ -91,7 +91,7 @@ class SMTP extends NotificationProvider {
let bodyTextContent = msg; let bodyTextContent = msg;
if (heartbeatJSON) { if (heartbeatJSON) {
bodyTextContent = `${msg}\nTime (UTC): ${heartbeatJSON["time"]}`; bodyTextContent = `${msg}\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`;
} }
// send mail with defined transport object // send mail with defined transport object

Loading…
Cancel
Save