uptime-kuma/server/notification-providers/onechat.js
Newton Langidrik 8cdf7a905a Rebrand to PSS Uptime: Add custom logo and favicon, update all references from Uptime Kuma to PSS Uptime
- Add custom logo.png and favicon.ico for Marshall Islands Public School System
- Update all application references from 'Uptime Kuma' to 'PSS Uptime'
- Update README.md with PSS Uptime branding and credits to original Uptime Kuma project
- Update Docker configuration to build from source
- Update all notification providers to use PSS Uptime branding
- Update UI components, layouts, and pages with new branding
- Update language files (en, zh-CN, zh-TW) with PSS Uptime translations
- Add logo URL input field in status page settings
- Update default icon references from icon.svg to logo.png
2026-01-20 13:47:09 +12:00

71 lines
2.5 KiB
JavaScript

const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { DOWN, UP } = require("../../src/util");
class OneChat extends NotificationProvider {
name = "OneChat";
/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
const url = "https://chat-api.one.th/message/api/v1/push_message";
try {
let config = {
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + notification.accessToken,
},
};
config = this.getAxiosConfigWithProxy(config);
if (heartbeatJSON == null) {
const testMessage = {
to: notification.recieverId,
bot_id: notification.botId,
type: "text",
message: "Test Successful!",
};
await axios.post(url, testMessage, config);
} else if (heartbeatJSON["status"] === DOWN) {
const downMessage = {
to: notification.recieverId,
bot_id: notification.botId,
type: "text",
message: `PSS Uptime Alert:
[🔴 Down]
Name: ${monitorJSON["name"]}
${heartbeatJSON["msg"]}
Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
};
await axios.post(url, downMessage, config);
} else if (heartbeatJSON["status"] === UP) {
const upMessage = {
to: notification.recieverId,
bot_id: notification.botId,
type: "text",
message: `PSS Uptime Alert:
[🟢 Up]
Name: ${monitorJSON["name"]}
${heartbeatJSON["msg"]}
Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
};
await axios.post(url, upMessage, config);
}
return okMsg;
} catch (error) {
// Handle errors and throw a descriptive message
if (error.response) {
const errorMessage = error.response.data?.message || "Unknown API error occurred.";
throw new Error(`OneChat API Error: ${errorMessage}`);
} else {
this.throwGeneralAxiosError(error);
}
}
}
}
module.exports = OneChat;