Repository: louislam/uptime-kuma
File: server/notification.js (JavaScript)

Code before:

            } catch (error) {
                throwGeneralAxiosError(error)
            }

        } else if (notification.type === "pushbullet") {
            try {
                let pushbulletUrl = "https://api.pushbullet.com/v2/pushes";
                let config = {
                    headers: {
                        "Access-Token": notification.pushbulletAccessToken,
                        "Content-Type": "application/json"
                    }
                };
                if (heartbeatJSON == null) {
                    let testdata = {
                        "type": "note",
                        "title": "Uptime Kuma Alert",
                        "body": "Testing Successful.",
                    }
                    await axios.post(pushbulletUrl, testdata, config)
                } else if (heartbeatJSON["status"] == 0) {
                    let downdata = {
                        "type": "note",
                        "title": "UptimeKuma Alert: " + monitorJSON["name"],
                        "body": "[🔴 Down]" + heartbeatJSON["msg"] + "\nTime (UTC):" + heartbeatJSON["time"],
                    }
                    await axios.post(pushbulletUrl, downdata, config)
                } else if (heartbeatJSON["status"] == 1) {
                    let updata = {
                        "type": "note",
                        "title": "UptimeKuma Alert: " + monitorJSON["name"],
                        "body": "[✅ Up]" + heartbeatJSON["msg"] + "\nTime (UTC):" + heartbeatJSON["time"],
                    }
                    await axios.post(pushbulletUrl, updata, config)
                }
                return okMsg;
            } catch (error) {
                throwGeneralAxiosError(error)
            }
        } else if (notification.type === "line") {
            try {
                let lineAPIUrl = "https://api.line.me/v2/bot/message/push";
                let config = {
                    headers: {
                        "Content-Type": "application/json",
                        "Authorization": "Bearer " + notification.lineChannelAccessToken
                    }
                };
                if (heartbeatJSON == null) {
                    let testMessage = {

Review comment (suggestion):
```suggestion
                        "body": "[🔴 Down] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"],
```

Code after:
                    return okMsg;
                }

            } catch (error) {
                throwGeneralAxiosError(error)
            }

        } else if (notification.type === "pushbullet") {
            try {
                let pushbulletUrl = "https://api.pushbullet.com/v2/pushes";
                let config = {
                    headers: {
                        "Access-Token": notification.pushbulletAccessToken,
                        "Content-Type": "application/json"
                    }
                };
                if (heartbeatJSON == null) {
                    let testdata = {
                        "type": "note",
                        "title": "Uptime Kuma Alert",
                        "body": "Testing Successful.",
                    }
                    await axios.post(pushbulletUrl, testdata, config)
                } else if (heartbeatJSON["status"] == DOWN) {
                    let downdata = {
                        "type": "note",
                        "title": "UptimeKuma Alert: " + monitorJSON["name"],
                        "body": "[🔴 Down] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"],
                    }
                    await axios.post(pushbulletUrl, downdata, config)
                } else if (heartbeatJSON["status"] == UP) {
                    let updata = {
                        "type": "note",
                        "title": "UptimeKuma Alert: " + monitorJSON["name"],
                        "body": "[✅ Up] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"],
                    }
                    await axios.post(pushbulletUrl, updata, config)
                }
                return okMsg;
            } catch (error) {
                throwGeneralAxiosError(error)
            }
        } else if (notification.type === "line") {
            try {
                let lineAPIUrl = "https://api.line.me/v2/bot/message/push";
                let config = {
                    headers: {
                        "Content-Type": "application/json",
                        "Authorization": "Bearer " + notification.lineChannelAccessToken
                    }
                };