|
|
|
@ -4601,21 +4601,25 @@ exports.getDisconnectedCustomerDetailsByTeamMemberId = async (req, reply) => {
|
|
|
|
|
const customerIds = [...new Set(disconnectedDevices.map(d => d.customerId))];
|
|
|
|
|
|
|
|
|
|
const users = await User.find({ customerId: { $in: customerIds } }).lean();
|
|
|
|
|
console.log("users",users)
|
|
|
|
|
|
|
|
|
|
// Step 6: Prepare final response
|
|
|
|
|
const response = users.map(user => ({
|
|
|
|
|
customerId: user.customerId,
|
|
|
|
|
firstName: user.profile?.firstName || "",
|
|
|
|
|
lastName: user.profile?.lastName || "",
|
|
|
|
|
address1: user.profile?.address1 || "",
|
|
|
|
|
address2: user.profile?.address2 || "",
|
|
|
|
|
|
|
|
|
|
phone: user.phone || user.profile?.contactNumber || "",
|
|
|
|
|
email: user.emails?.[0]?.email || "",
|
|
|
|
|
city: user.profile?.city || "",
|
|
|
|
|
state: user.profile?.state || "",
|
|
|
|
|
country: user.profile?.country || "",
|
|
|
|
|
|
|
|
|
|
latitude: user.latitude,
|
|
|
|
|
longitude: user.longitude,
|
|
|
|
|
fcmIds: (user.fcmIds || []).filter(fcm => typeof fcm === "string"),
|
|
|
|
|
installationId: user.installationId || "",
|
|
|
|
|
username: user.username || "",
|
|
|
|
|
buildingName: user.buildingName || "",
|
|
|
|
|
notificationPreferences: {
|
|
|
|
|
allowNotifications: user.allowNotifications || false,
|
|
|
|
|
automaticStartAndStopNotify: user.automaticStartAndStopNotify || false,
|
|
|
|
|