assetmodel creation and adding for namespace socket

This commit is contained in:
2025-04-01 13:27:25 +05:30
parent d8d9a7c837
commit 5db6153bb9
13 changed files with 1241 additions and 828 deletions

View File

@@ -3,6 +3,7 @@ import userModel from "../../../shared/model/user-Model.ts"
export const activeUsers = async (data: any) => {
const {organization}=data
// console.log('data: ', data);
try {
if (data && data.email) {
@@ -43,7 +44,7 @@ export const activeUsers = async (data: any) => {
// Handle the error or return a default value
// Example: Return an error response if the email is invalid
return { success: false, message: 'Email is missing or invalid', }
return { success: false, message: 'Email is missing or invalid', organization:organization }
// return res.status(400).send({ message: 'Email is missing or invalid' });
}
@@ -99,3 +100,38 @@ export const activeUserOffline = async (data: any) => {
// return { success: false, message: error}
}
}
type OnlineUsersMap = Map<string, Set<string>>;
// export const addUserToOnlineList = async (
// organization: string,
// email: string,
// onlineUsers: OnlineUsersMap,
// socket: any,
// namespace: string
// ) => {
// if (!organization || !email) return;
// console.log('organization: ', organization);
// // Ensure the organization entry exists
// if (!onlineUsers.has(organization)) {
// onlineUsers.set(organization, new Set());
// }
// const findUser = await userModel(organization).findOne({email})
// if (!findUser) {
// return { success: false, message: "User not found", organization };
// }
// const userId = findUser._id;
// console.log(`🔍 Found user with ID: ${userId}`);
// // Add user to the online set
// onlineUsers.get(organization)!.add(userId);
// console.log(`✅ User ${userId} is online (Org: ${organization})`);
// // Emit updated online users list
// socket.emit("users:online", {
// organization,
// users: [...onlineUsers.get(organization)!],
// });
// };