uptime-kuma/server/notification-providers/lunasea.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

69 lines
2.3 KiB
JavaScript

const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { DOWN, UP } = require("../../src/util");
class LunaSea extends NotificationProvider {
name = "lunasea";
/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
const url = "https://notify.lunasea.app/v1";
try {
let config = this.getAxiosConfigWithProxy({});
const target = this.getTarget(notification);
if (heartbeatJSON == null) {
let testdata = {
title: "Uptime Kuma Alert",
body: msg,
};
await axios.post(`${url}/custom/${target}`, testdata, config);
return okMsg;
}
if (heartbeatJSON["status"] === DOWN) {
let downdata = {
title: "PSS Uptime Alert: " + monitorJSON["name"],
body:
"[🔴 Down] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
};
await axios.post(`${url}/custom/${target}`, downdata, config);
return okMsg;
}
if (heartbeatJSON["status"] === UP) {
let updata = {
title: "PSS Uptime Alert: " + monitorJSON["name"],
body:
"[✅ Up] " +
heartbeatJSON["msg"] +
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
};
await axios.post(`${url}/custom/${target}`, updata, config);
return okMsg;
}
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
/**
* Generates the lunasea target to send the notification to
* @param {BeanModel} notification Notification details
* @returns {string} The target to send the notification to
*/
getTarget(notification) {
if (notification.lunaseaTarget === "user") {
return "user/" + notification.lunaseaUserID;
}
return "device/" + notification.lunaseaDevice;
}
}
module.exports = LunaSea;