uptime-kuma/server/notification-providers/notification-provider.js

37 lines
1 KiB
JavaScript
Raw Normal View History

2021-09-07 07:42:46 -07:00
class NotificationProvider {
/**
* Notification Provider Name
* @type string
*/
name = undefined;
/**
* @param notification : BeanModel
* @param msg : string General Message
* @param monitorJSON : object Monitor details (For Up/Down only)
* @param heartbeatJSON : object Heartbeat details (For Up/Down only)
* @returns {Promise<string>} Return Successful Message
* Throw Error with fail msg
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
throw new Error("Have to override Notification.send(...)");
}
throwGeneralAxiosError(error) {
let msg = "Error: " + error + " ";
if (error.response && error.response.data) {
if (typeof error.response.data === "string") {
msg += error.response.data;
} else {
2022-04-13 09:30:32 -07:00
msg += JSON.stringify(error.response.data);
2021-09-07 07:42:46 -07:00
}
}
2022-04-13 09:30:32 -07:00
throw new Error(msg);
2021-09-07 07:42:46 -07:00
}
}
module.exports = NotificationProvider;