diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index f8b2f609..f3d6102f 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -1766,7 +1766,7 @@ const sendNotification = async (fcmIds, title, body) => { notification: { title, body }, token, data: { - exampleKey: 'exampleValue', + 'target': '/tank_levels', }, }); console.log(`Notification sent successfully to token: ${token}`, response); @@ -2150,16 +2150,17 @@ const checkWaterLevelsAndNotify = async (customerId, tankName, tankLocation, fcm } else if (waterLevelPercentage <= thresholds.low) { eventEmitter.emit('sendLowWaterNotification', fcmTokens, tank); await Tank.updateOne({ customerId, tankName: tank.tankName }, { $set: { notificationSentLow: true } }); - } else if (waterLevelPercentage >= thresholds.criticallyHigh) { - eventEmitter.emit('sendCriticalHighWaterNotification', fcmTokens, tank); - await Tank.updateOne({ customerId, tankName: tank.tankName }, { $set: { notificationSentCriticalHigh: true } }); - } else if (waterLevelPercentage >= thresholds.veryHigh) { - eventEmitter.emit('sendVeryHighWaterNotification', fcmTokens, tank); - await Tank.updateOne({ customerId, tankName: tank.tankName }, { $set: { notificationSentVeryHigh: true } }); - } else if (waterLevelPercentage >= thresholds.high) { - eventEmitter.emit('sendHighWaterNotification', fcmTokens, tank); - await Tank.updateOne({ customerId, tankName: tank.tankName }, { $set: { notificationSentHigh: true } }); } + // else if (waterLevelPercentage >= thresholds.criticallyHigh) { + // eventEmitter.emit('sendCriticalHighWaterNotification', fcmTokens, tank); + // await Tank.updateOne({ customerId, tankName: tank.tankName }, { $set: { notificationSentCriticalHigh: true } }); + // } else if (waterLevelPercentage >= thresholds.veryHigh) { + // eventEmitter.emit('sendVeryHighWaterNotification', fcmTokens, tank); + // await Tank.updateOne({ customerId, tankName: tank.tankName }, { $set: { notificationSentVeryHigh: true } }); + // } else if (waterLevelPercentage >= thresholds.high) { + // eventEmitter.emit('sendHighWaterNotification', fcmTokens, tank); + // await Tank.updateOne({ customerId, tankName: tank.tankName }, { $set: { notificationSentHigh: true } }); + // } } catch (error) { console.error(`Error checking water levels for tank ${tankName}:`, error); }