fix ESLint issues in OneChat.js

This commit is contained in:
Pargorn.Ru 2025-01-17 19:47:10 +07:00
parent dab089086c
commit ef9b6d2be8

View file

@ -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;