mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-20 06:02:33 +02:00

Some checks failed
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20, ARM64) (push) Has been cancelled
Auto Test / auto-test (20, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20, windows-latest) (push) Has been cancelled
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / check-linters (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
validate / json-yaml-validate (push) Has been cancelled
validate / validate (push) Has been cancelled
Co-authored-by: Frank Elsinga <frank@elsinga.de>
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
const { getMonitorRelativeURL, UP } = require("../../src/util");
|
|
const { setting } = require("../util-server");
|
|
const NotificationProvider = require("./notification-provider");
|
|
const axios = require("axios");
|
|
|
|
class Notifery extends NotificationProvider {
|
|
name = "notifery";
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
|
const okMsg = "Sent Successfully.";
|
|
const url = "https://api.notifery.com/event";
|
|
|
|
let data = {
|
|
title: notification.notiferyTitle || "Uptime Kuma Alert",
|
|
message: msg,
|
|
};
|
|
|
|
if (notification.notiferyGroup) {
|
|
data.group = notification.notiferyGroup;
|
|
}
|
|
|
|
// Link to the monitor
|
|
const baseURL = await setting("primaryBaseURL");
|
|
if (baseURL && monitorJSON) {
|
|
data.message += `\n\nMonitor: ${baseURL}${getMonitorRelativeURL(monitorJSON.id)}`;
|
|
}
|
|
|
|
if (heartbeatJSON) {
|
|
data.code = heartbeatJSON.status === UP ? 0 : 1;
|
|
|
|
if (heartbeatJSON.ping) {
|
|
data.duration = heartbeatJSON.ping;
|
|
}
|
|
}
|
|
|
|
try {
|
|
const headers = {
|
|
"Content-Type": "application/json",
|
|
"x-api-key": notification.notiferyApiKey,
|
|
};
|
|
|
|
await axios.post(url, data, { headers });
|
|
return okMsg;
|
|
} catch (error) {
|
|
this.throwGeneralAxiosError(error);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Notifery;
|