diff --git a/server/notification.js b/server/notification.js index 9da8a0dc8..9785fc8f5 100644 --- a/server/notification.js +++ b/server/notification.js @@ -192,6 +192,25 @@ class Notification { throwGeneralAxiosError(error) } + }else if (notification.type === "pushy") { + try { + await axios.post(`https://api.pushy.me/push?api_key=${notification.pushyAPIKey}`, { + "to": notification.pushyToken, + "data": { + "message": "Uptime-Kuma" + }, + "notification": { + "body": msg, + "badge": 1, + "sound": "ping.aiff" + } + }) + return true; + } catch (error) { + console.log(error) + return false; + } + } else if (notification.type === "pushover") { var pushoverlink = 'https://api.pushover.net/1/messages.json' try { @@ -219,11 +238,6 @@ class Notification { } catch (error) { throwGeneralAxiosError(error) } - - } else if (notification.type === "apprise") { - - return Notification.apprise(notification, msg) - } else { throw new Error("Notification type is not supported") } @@ -287,31 +301,6 @@ class Notification { return "Sent Successfully."; } - - static async apprise(notification, msg) { - let s = child_process.spawnSync("apprise", [ "-vv", "-b", msg, notification.appriseURL]) - - - let output = (s.stdout) ? s.stdout.toString() : 'ERROR: maybe apprise not found'; - - if (output) { - - if (! output.includes("ERROR")) { - return "Sent Successfully"; - } else { - throw new Error(output) - } - } else { - return "" - } - } - - static checkApprise() { - let commandExistsSync = require('command-exists').sync; - let exists = commandExistsSync('apprise'); - return exists; - } - } function throwGeneralAxiosError(error) { diff --git a/server/server.js b/server/server.js index 6bf48dc13..56a5156f5 100644 --- a/server/server.js +++ b/server/server.js @@ -471,15 +471,6 @@ let needSetup = false; }); } }); - - socket.on("checkApprise", async (callback) => { - try { - checkLogin(socket) - callback(Notification.checkApprise()); - } catch (e) { - callback(false); - } - }); }); console.log("Init") diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index afbfc0d4e..dae8e88ff 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -21,7 +21,7 @@ - + @@ -221,6 +221,23 @@ + + - - -