mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-06 19:53:50 +00:00
fix ESLint issues in OneChat.js
This commit is contained in:
parent
dab089086c
commit
ef9b6d2be8
1 changed files with 29 additions and 11 deletions
|
@ -34,10 +34,17 @@ class OneChat extends NotificationProvider {
|
|||
bot_id: notification.botId,
|
||||
type: "text",
|
||||
message:
|
||||
`UptimeKuma Alert:\n[🔴 Down]\n` +
|
||||
`Name: ${monitorJSON["name"]}\n` +
|
||||
`${heartbeatJSON["msg"]}\n` +
|
||||
`Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
|
||||
"UptimeKuma Alert:\n" +
|
||||
"[🔴 Down]\n" +
|
||||
"Name: " +
|
||||
monitorJSON["name"] +
|
||||
"\n" +
|
||||
heartbeatJSON["msg"] +
|
||||
"\n" +
|
||||
"Time (" +
|
||||
heartbeatJSON["timezone"] +
|
||||
"): " +
|
||||
heartbeatJSON["localDateTime"],
|
||||
};
|
||||
await axios.post(url, downMessage, config);
|
||||
} else if (heartbeatJSON["status"] === UP) {
|
||||
|
@ -46,10 +53,17 @@ class OneChat extends NotificationProvider {
|
|||
bot_id: notification.botId,
|
||||
type: "text",
|
||||
message:
|
||||
`UptimeKuma Alert:\n[✅ Up]\n` +
|
||||
`Name: ${monitorJSON["name"]}\n` +
|
||||
`${heartbeatJSON["msg"]}\n` +
|
||||
`Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
|
||||
"UptimeKuma Alert:\n" +
|
||||
"[🟢 Up]\n" +
|
||||
"Name: " +
|
||||
monitorJSON["name"] +
|
||||
"\n" +
|
||||
heartbeatJSON["msg"] +
|
||||
"\n" +
|
||||
"Time (" +
|
||||
heartbeatJSON["timezone"] +
|
||||
"): " +
|
||||
heartbeatJSON["localDateTime"],
|
||||
};
|
||||
await axios.post(url, upMessage, config);
|
||||
}
|
||||
|
@ -58,13 +72,17 @@ class OneChat extends NotificationProvider {
|
|||
} catch (error) {
|
||||
// Handle errors and throw a descriptive message
|
||||
if (error.response) {
|
||||
const errorMessage = error.response.data?.message || "Unknown API error occurred.";
|
||||
const errorMessage =
|
||||
error.response.data?.message ||
|
||||
"Unknown API error occurred.";
|
||||
throw new Error(`OneChat API Error: ${errorMessage}`);
|
||||
} else {
|
||||
throw new Error(`Network or unexpected error: ${error.message}`);
|
||||
throw new Error(
|
||||
`Network or unexpected error: ${error.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = OneChat;
|
||||
module.exports = OneChat;
|
||||
|
|
Loading…
Add table
Reference in a new issue