diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 27d6f5d7..a7b682c2 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -2889,27 +2889,19 @@ exports.motorAction = async (req, reply) => { let hasNotifiedStart = false; let hasNotifiedStop = false; if (action === "start") { - motorStopStatus = "2"; const startTime = req.body.startTime; - await Tank.updateOne( { customerId, "connections.inputConnections.motor_id": motorId }, { $set: { "connections.inputConnections.$.motor_stop_status": motorStopStatus } } ); - const thresholdTimeMs = req.body.manual_threshold_time * 60 * 1000; // Convert minutes to milliseconds const stopCriteria = motorOnType === "time" ? `${req.body.manual_threshold_time} minutes` - : `${req.body.manual_threshold_litres} litres`; - - // await checkWaterLevelsAndNotify(customerId, tankName, receiverTank.tankLocation, fcmToken); - + : `${req.body.manual_threshold_litres} litres`; try { - - // eventEmitter.emit("motorStart", customerId, fcmToken, tankName, blockName, startTime, "Mobile APP", manual_threshold_time, typeOfWater); - eventEmitter.emit( + eventEmitter.emit( "motorStart", customerId, fcmToken, @@ -3100,6 +3092,13 @@ exports.motorAction = async (req, reply) => { // fcmToken, // `Motor has reached its time threshold of ${req.body.manual_threshold_time} minutes and will stop.` // ); + eventEmitter.emit( + "sendThresholdTimeNotification", + customerId, + fcmToken, + manual_threshold_time, + motorId + ); const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm'); await Tank.updateOne( { customerId, "connections.inputConnections.motor_id": motorId },