summaryrefslogtreecommitdiffstats
path: root/server/notification-providers/techulus-push.js
blob: bf688b194d41128ef1f0503b326ab773cc49a311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const NotificationProvider = require("./notification-provider");
const axios = require("axios");

class TechulusPush extends NotificationProvider {
    name = "PushByTechulus";

    /**
     * @inheritdoc
     */
    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        const okMsg = "Sent Successfully.";

        let data = {
            "title": notification?.pushTitle?.length ? notification.pushTitle : "Uptime-Kuma",
            "body": msg,
            "timeSensitive": notification.pushTimeSensitive ?? true,
        };

        if (notification.pushChannel) {
            data.channel = notification.pushChannel;
        }

        if (notification.pushSound) {
            data.sound = notification.pushSound;
        }

        try {
            await axios.post(`https://push.techulus.com/api/v1/notify/${notification.pushAPIKey}`, data);
            return okMsg;
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = TechulusPush;