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

Code before:
                });

            } catch (e) {
                console.error(e)

                callback({
                    ok: false,
                    msg: e.message,
                });
            }
        });

        socket.on("checkApprise", async (callback) => {
            try {
                checkLogin(socket)
                callback(Notification.checkApprise());
            } catch (e) {
                callback(false);
            }
        });

        socket.on("uploadBackup", async (uploadedJSON, callback) => {
            try {
                checkLogin(socket)

                console.log(`Import Backup User ID: ${socket.userID}`)

                let notificationList = uploadedJSON[0];
                let monitorList = uploadedJSON[1];

                monitorList = JSON.stringify(monitorList);
                monitorList = JSON.parse(monitorList);
                monitorList = Object.values(monitorList);

                if (notificationList.length >= 1) {
                    for (let i = 0; i < notificationList.length; i++) {
                        let notification = JSON.parse(notificationList[i].config);
                        await Notification.save(notification, null, socket.userID)
                    }
                }

                if (monitorList.length >= 1) {
                    for (let i = 0; i < monitorList.length; i++) {
                        let monitor = {
                            name: monitorList[i].name,
                            type: monitorList[i].type,
                            url: monitorList[i].url,
                            interval: monitorList[i].interval,
                            hostname: monitorList[i].hostname,
                            maxretries: monitorList[i].maxretries,
                            port: monitorList[i].port,

Review comment (suggestion):
```suggestion
                console.log(`Importing Backup, User ID: ${socket.userID}`)
```

Code after:
                    ok: true,
                    msg: "Saved",
                });

            } catch (e) {
                callback({
                    ok: false,
                    msg: e.message,
                });
            }
        });

        socket.on("deleteNotification", async (notificationID, callback) => {
            try {
                checkLogin(socket)

                await Notification.delete(notificationID, socket.userID)
                await sendNotificationList(socket)

                callback({
                    ok: true,
                    msg: "Deleted",
                });

            } catch (e) {
                callback({
                    ok: false,
                    msg: e.message,
                });
            }
        });

        socket.on("testNotification", async (notification, callback) => {
            try {
                checkLogin(socket)

                let msg = await Notification.send(notification, notification.name + " Testing")

                callback({
                    ok: true,
                    msg,
                });

            } catch (e) {
                console.error(e)

                callback({
                    ok: false,
                    msg: e.message,
                });
            }