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

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

Loading…
Cancel
Save