summaryrefslogtreecommitdiffstats
path: root/server/notification-providers/signal.js
blob: 9702d06bbf2d3d928d1a52d402d00d0809514ef5 (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
const NotificationProvider = require("./notification-provider");
const axios = require("axios");

class Signal extends NotificationProvider {
    name = "signal";

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

        try {
            let data = {
                "message": msg,
                "number": notification.signalNumber,
                "recipients": notification.signalRecipients.replace(/\s/g, "").split(","),
            };
            let config = {};

            await axios.post(notification.signalURL, data, config);
            return okMsg;
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = Signal;