diff --git a/server/server.js b/server/server.js index 8d375b62c..4aec2b275 100644 --- a/server/server.js +++ b/server/server.js @@ -767,30 +767,6 @@ let needSetup = false; } }); - socket.on("getMaintenance", async (maintenanceID, callback) => { - try { - checkLogin(socket); - - console.log(`Get Maintenance: ${maintenanceID} User ID: ${socket.userID}`); - - let bean = await R.findOne("maintenance", " id = ? AND user_id = ? ", [ - maintenanceID, - socket.userID, - ]); - - callback({ - ok: true, - maintenance: await bean.toJSON(), - }); - - } catch (e) { - callback({ - ok: false, - msg: e.message, - }); - } - }); - socket.on("getMonitorBeats", async (monitorID, period, callback) => { try { checkLogin(socket); diff --git a/server/socket-handlers/maintenance-socket-handler.js b/server/socket-handlers/maintenance-socket-handler.js index e93d8d60d..113c336a7 100644 --- a/server/socket-handlers/maintenance-socket-handler.js +++ b/server/socket-handlers/maintenance-socket-handler.js @@ -139,6 +139,30 @@ module.exports.maintenanceSocketHandler = (socket) => { } }); + socket.on("getMaintenance", async (maintenanceID, callback) => { + try { + checkLogin(socket); + + log.debug("maintenance", `Get Maintenance: ${maintenanceID} User ID: ${socket.userID}`); + + let bean = await R.findOne("maintenance", " id = ? AND user_id = ? ", [ + maintenanceID, + socket.userID, + ]); + + callback({ + ok: true, + maintenance: await bean.toJSON(), + }); + + } catch (e) { + callback({ + ok: false, + msg: e.message, + }); + } + }); + socket.on("getMaintenanceList", async (callback) => { try { checkLogin(socket); @@ -159,7 +183,7 @@ module.exports.maintenanceSocketHandler = (socket) => { try { checkLogin(socket); - console.log(`Get Monitors for Maintenance: ${maintenanceID} User ID: ${socket.userID}`); + log.debug("maintenance", `Get Monitors for Maintenance: ${maintenanceID} User ID: ${socket.userID}`); let monitors = await R.getAll("SELECT monitor.id, monitor.name FROM monitor_maintenance mm JOIN monitor ON mm.monitor_id = monitor.id WHERE mm.maintenance_id = ? ", [ maintenanceID, @@ -183,7 +207,7 @@ module.exports.maintenanceSocketHandler = (socket) => { try { checkLogin(socket); - console.log(`Get Status Pages for Maintenance: ${maintenanceID} User ID: ${socket.userID}`); + log.debug("maintenance", `Get Status Pages for Maintenance: ${maintenanceID} User ID: ${socket.userID}`); let statusPages = await R.getAll("SELECT status_page.id, status_page.title FROM maintenance_status_page msp JOIN status_page ON msp.status_page_id = status_page.id WHERE msp.maintenance_id = ? ", [ maintenanceID, @@ -207,7 +231,7 @@ module.exports.maintenanceSocketHandler = (socket) => { try { checkLogin(socket); - console.log(`Delete Maintenance: ${maintenanceID} User ID: ${socket.userID}`); + log.debug("maintenance", `Delete Maintenance: ${maintenanceID} User ID: ${socket.userID}`); if (maintenanceID in server.maintenanceList) { delete server.maintenanceList[maintenanceID];