master^2
Bhaskar 9 months ago
parent 1806a3f39a
commit adfd395718

@ -1584,15 +1584,15 @@ eventEmitter.on(
console.log("users", users); console.log("users", users);
const userNames = users.map(user => user.username).join(', '); const userNames = users.map(user => user.username).join(', ');
console.log("userNames", userNames); console.log("userNames", userNames);
const startMethod = motorOnType.toUpperCase() === "APP" ? "via the App" : "Manual"; const startMethod = motorOnType === "APP" ? "via the App" : "Manual";
// Prepare the message // Prepare the message
const message = const message =
`Tank Name: '${tankName}'\n` + `🚰 Tank Name: '${tankName}'\n` +
`Pump started at: '${startTime}'\n` + `🕒 Pump started at: '${startTime}'\n` +
`Initiated by : ${userNames}\n` + `👤 Initiated by : ${userNames}\n` +
// `Pump started by: '${motorOnType.toUpperCase()}'\n` + // `Pump started by: '${motorOnType.toUpperCase()}'\n` +
`Pump started by: '${startMethod}'\n` + `🔄 Pump started by: '${startMethod}'\n` +
`Will stop at after: '${manual_threshold_time}' mins`; `Will stop at after: '${manual_threshold_time}' mins`;
// Send the notification // Send the notification
@ -1612,14 +1612,14 @@ eventEmitter.on('motorStop', async (fcmTokens, tankName,stopTime, motorOnType)
const userNames = users.map(user => user.username).join(', '); const userNames = users.map(user => user.username).join(', ');
console.log("userNames",userNames) console.log("userNames",userNames)
const stopMethod = motorOnType.toUpperCase() === "APP" ? "via the App" : "manual"; const stopMethod = motorOnType === "APP" ? "via the App" : "manual";
// Prepare the message // Prepare the message
// const message = `Tank Name: '${tankName}', Pump stopped at '${stopTime}' by Initiated by user(s): ${userNames} '${motorOnType}'`; // const message = `Tank Name: '${tankName}', Pump stopped at '${stopTime}' by Initiated by user(s): ${userNames} '${motorOnType}'`;
const message = const message =
`Tank Name: '${tankName}'\n` + `🚰 Tank Name: '${tankName}'\n` +
`Pump stopped at: '${stopTime}'\n` + `🕒 Pump stopped at: '${stopTime}'\n` +
`Initiated by : ${userNames}\n` + `👤 Initiated by : ${userNames}\n` +
// `Motor Off Type: '${motorOnType}'`; // `Motor Off Type: '${motorOnType}'`;
`Motor Off Type: '${stopMethod}'`; `Motor Off Type: '${stopMethod}'`;
@ -1717,7 +1717,7 @@ eventEmitter.on(
// Retrieve the user information // Retrieve the user information
const users = await User.find({ fcmIds: { $in: fcmTokens } }); const users = await User.find({ fcmIds: { $in: fcmTokens } });
const userNames = users.map(user => user.username).join(', '); const userNames = users.map(user => user.username).join(', ');
const startMethod = motorOnType.toUpperCase() === "Forced Manual"; const startMethod = motorOnType === "Forced Manual";
// Prepare the message // Prepare the message
const message = const message =
@ -1745,14 +1745,14 @@ eventEmitter.on(
// Retrieve the user information // Retrieve the user information
const users = await User.find({ fcmIds: { $in: fcmTokens } }); const users = await User.find({ fcmIds: { $in: fcmTokens } });
const userNames = users.map(user => user.username).join(', '); const userNames = users.map(user => user.username).join(', ');
const stopMethod = motorOnType.toUpperCase() === "Forced Manual"; const stopMethod = motorOnType === "Forced Manual";
// Prepare the message // Prepare the message
const message = const message =
`🚰 Tank Name: '${tankName}'\n` + `🚰 Tank Name: '${tankName}'\n` +
`🕒 Pump stopped at: '${stopTime}'\n` + `🕒 Pump stopped at: '${stopTime}'\n` +
`👤 Initiated by: ${userNames}\n` + `👤 Initiated by: ${userNames}\n` +
`🔄 Pump stopped by: '${stopMethod}'\n`; `Motor Off Type: '${stopMethod}'\n`;
// Send the notification // Send the notification
await sendNotification(fcmTokens, 'Motor Stopped 🛑', message); await sendNotification(fcmTokens, 'Motor Stopped 🛑', message);
@ -2372,7 +2372,7 @@ exports.motorAction = async (req, reply) => {
blockName, blockName,
tankName, tankName,
startTime, startTime,
motorOnType, "APP",
manual_threshold_time manual_threshold_time
); );
notificationSentStatus.motorStart = true; // Set flag to true to prevent duplicate notifications notificationSentStatus.motorStart = true; // Set flag to true to prevent duplicate notifications
@ -2420,7 +2420,7 @@ exports.motorAction = async (req, reply) => {
fcmToken, fcmToken,
tankName, tankName,
stopTime, stopTime,
motorOnType "APP"
); );
notificationSentStatus.motorStop = true; // Set flag to true to prevent duplicate notifications notificationSentStatus.motorStop = true; // Set flag to true to prevent duplicate notifications
} }

Loading…
Cancel
Save