From b27bfea44139d8ed5001ff61811d8f8298c71a12 Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Tue, 11 Mar 2025 17:00:06 +0530 Subject: [PATCH] commented on sendthrold notification --- src/controllers/tanksController.js | 68 +++++++++++++++--------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index c48818d6..fe181c95 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -1572,18 +1572,18 @@ eventEmitter.on('sendCriticalHighWaterNotification', async (fcmTokens, tankInfo, // }); -eventEmitter.on('sendThresholdTimeNotification', async (customerId, fcmTokens, thresholdTime, hw_Id, tankName, blockName) => { - try { - const message = - `🛢️ Tank Name: '${tankName}'\n` + - `🏢 Block Name: '${blockName}'\n` + - `Motor Stopped as it completed ${thresholdTime} minutes.`; - await sendNotification(hw_Id, customerId, fcmTokens, 'Motor Alert', message); - console.log("Threshold time notification sent successfully."); - } catch (error) { - console.error("Error sending threshold time notification:", error); - } -}); +// eventEmitter.on('sendThresholdTimeNotification', async (customerId, fcmTokens, thresholdTime, hw_Id, tankName, blockName) => { +// try { +// const message = +// `🛢️ Tank Name: '${tankName}'\n` + +// `🏢 Block Name: '${blockName}'\n` + +// `Motor Stopped as it completed ${thresholdTime} minutes.`; +// await sendNotification(hw_Id, customerId, fcmTokens, 'Motor Alert', message); +// console.log("Threshold time notification sent successfully."); +// } catch (error) { +// console.error("Error sending threshold time notification:", error); +// } +// }); // eventEmitter.on( // 'sendMotorStartNotification', @@ -3100,29 +3100,29 @@ exports.motorAction = async (req, reply) => { const notificationKey = `${customerId}_${motorId}_threshold`; // Check if the notification has already been sent - if (!notificationTracker.get(notificationKey)) { - console.log("Sending threshold time notification..."); + // if (!notificationTracker.get(notificationKey)) { + // console.log("Sending threshold time notification..."); - eventEmitter.emit( - "sendThresholdTimeNotification", - customerId, - fcmToken, - manual_threshold_time, - motorId, - tankName, - blockName - ); - - // Mark notification as sent - notificationTracker.set(notificationKey, true); - - // Optionally, reset the flag after some time (e.g., 24 hours) - setTimeout(() => { - notificationTracker.delete(notificationKey); - }, 24 * 60 * 60 * 1000); // Reset after 24 hours - } else { - console.log("Notification already sent, skipping..."); - } + // eventEmitter.emit( + // "sendThresholdTimeNotification", + // customerId, + // fcmToken, + // manual_threshold_time, + // motorId, + // tankName, + // blockName + // ); + + // // Mark notification as sent + // notificationTracker.set(notificationKey, true); + + // // Optionally, reset the flag after some time (e.g., 24 hours) + // setTimeout(() => { + // notificationTracker.delete(notificationKey); + // }, 24 * 60 * 60 * 1000); // Reset after 24 hours + // } else { + // console.log("Notification already sent, skipping..."); + // } const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm'); await Tank.updateOne(