diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index dc3e7a4b..268917aa 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -6867,7 +6867,6 @@ client.on('connect', () => { // } // }); - client.on('message', async (topic, message) => { console.log(`Message received on topic ${topic}:`, message.toString()); @@ -6961,45 +6960,19 @@ client.on('message', async (topic, message) => { // Find the inputConnection for the motor and update motor status const inputConnection = motorTank.connections.inputConnections.find(conn => conn.motor_id === hw_Id); // Updated variable name - const user = await User.findOne({ customerId: motorTank.customerId }); // Fetch user by customerId - const allowNotifications = user?.manualStartAndStopNotify ?? true; // Default to true if not set - if (inputConnection) { inputConnection.motor_status = status; // Update motor status - const tankName = motorTank.tankName; - if (allowNotifications && inputConnection.motor_stop_status === "1" && status === 2 && inputConnection.motor_on_type !== "forced_manual") { + if (inputConnection.motor_stop_status === "1" && status === 2 && inputConnection.motor_on_type !== "forced_manual") { const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm'); inputConnection.motor_stop_status = "2"; inputConnection.motor_on_type = "forced_manual"; inputConnection.startTime = currentTime; - - eventEmitter.emit( - "sendMotorStartNotification", - fcmToken, // FCM tokens - hw_Id, // Motor ID - inputConnection.water_level || 0, // Water level - motorTank.blockName || "N/A", // Block name - tankName, // Tank name - inputConnection.motor_on_type, // Motor on type - "threshold", // Stop criteria - manual_threshold_time // Threshold time in mins - ); } - if (allowNotifications && inputConnection.motor_stop_status === "2" && status === 1) { + if (inputConnection.motor_stop_status === "2" && status === 1) { const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm'); inputConnection.motor_stop_status = "1"; inputConnection.stopTime = currentTime; - - eventEmitter.emit( - "sendMotorStopNotification", - fcmToken, // FCM tokens - hw_Id, // Motor ID - inputConnection.water_level || 0, // Water level - motorTank.blockName || "N/A", // Block name - tankName, // Tank name - inputConnection.motor_on_type // Motor on type - ); } await motorTank.save(); // Save the updated tank @@ -7016,6 +6989,8 @@ client.on('message', async (topic, message) => { + + exports.getPendingAndCompletedsurveyOfparticularInstaller = async (request, reply) => { try { const { installationId } = request.params;