Merge remote-tracking branch 'origin/master-AIO' into feature/IO-2776-cdk-fortellis
# Conflicts: # client/src/components/dms-post-form/dms-post-form.component.jsx # package-lock.json # package.json # server/web-sockets/redisSocketEvents.js
This commit is contained in:
@@ -38,6 +38,7 @@ const redisSocketEvents = ({
|
||||
try {
|
||||
const user = await admin.auth().verifyIdToken(token);
|
||||
socket.user = user;
|
||||
socket.bodyshopId = bodyshopId;
|
||||
await addUserSocketMapping(user.email, socket.id, bodyshopId);
|
||||
next();
|
||||
} catch (error) {
|
||||
@@ -67,12 +68,8 @@ const redisSocketEvents = ({
|
||||
return;
|
||||
}
|
||||
socket.user = user;
|
||||
socket.bodyshopId = bodyshopId;
|
||||
await refreshUserSocketTTL(user.email, bodyshopId);
|
||||
createLogEvent(
|
||||
socket,
|
||||
"debug",
|
||||
`Token updated successfully for socket ID: ${socket.id} (bodyshop: ${bodyshopId})`
|
||||
);
|
||||
socket.emit("token-updated", { success: true });
|
||||
} catch (error) {
|
||||
if (error.code === "auth/id-token-expired") {
|
||||
@@ -94,7 +91,6 @@ const redisSocketEvents = ({
|
||||
try {
|
||||
const room = getBodyshopRoom(bodyshopUUID);
|
||||
socket.join(room);
|
||||
// createLogEvent(socket, "debug", `Client joined bodyshop room: ${room}`);
|
||||
} catch (error) {
|
||||
createLogEvent(socket, "error", `Error joining room: ${error}`);
|
||||
}
|
||||
@@ -104,7 +100,6 @@ const redisSocketEvents = ({
|
||||
try {
|
||||
const room = getBodyshopRoom(bodyshopUUID);
|
||||
socket.leave(room);
|
||||
createLogEvent(socket, "debug", `Client left bodyshop room: ${room}`);
|
||||
} catch (error) {
|
||||
createLogEvent(socket, "error", `Error joining room: ${error}`);
|
||||
}
|
||||
@@ -114,8 +109,6 @@ const redisSocketEvents = ({
|
||||
try {
|
||||
const room = getBodyshopRoom(bodyshopUUID);
|
||||
io.to(room).emit("bodyshop-message", message);
|
||||
// We do not need this as these can be debugged live
|
||||
// createLogEvent(socket, "debug", `Broadcast message to bodyshop ${room}`);
|
||||
} catch (error) {
|
||||
createLogEvent(socket, "error", `Error getting room: ${error}`);
|
||||
}
|
||||
@@ -201,7 +194,6 @@ const redisSocketEvents = ({
|
||||
const registerSyncEvents = (socket) => {
|
||||
socket.on("sync-notification-read", async ({ email, bodyshopId, notificationId }) => {
|
||||
try {
|
||||
const userEmail = socket.user.email;
|
||||
const socketMapping = await getUserSocketMappingByBodyshop(email, bodyshopId);
|
||||
const timestamp = new Date().toISOString();
|
||||
|
||||
@@ -212,11 +204,6 @@ const redisSocketEvents = ({
|
||||
io.to(socketId).emit("sync-notification-read", { notificationId, timestamp });
|
||||
}
|
||||
});
|
||||
createLogEvent(
|
||||
socket,
|
||||
"debug",
|
||||
`Synced notification ${notificationId} read for ${userEmail} in bodyshop ${bodyshopId}`
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
createLogEvent(socket, "error", `Error syncing notification read: ${error.message}`);
|
||||
@@ -235,7 +222,6 @@ const redisSocketEvents = ({
|
||||
io.to(socketId).emit("sync-all-notifications-read", { timestamp });
|
||||
}
|
||||
});
|
||||
createLogEvent(socket, "debug", `Synced all notifications read for ${email} in bodyshop ${bodyshopId}`);
|
||||
}
|
||||
} catch (error) {
|
||||
createLogEvent(socket, "error", `Error syncing all notifications read: ${error.message}`);
|
||||
@@ -301,12 +287,34 @@ const redisSocketEvents = ({
|
||||
});
|
||||
};
|
||||
|
||||
// Task Events
|
||||
const registerTaskEvents = (socket) => {
|
||||
socket.on("task-created", (payload) => {
|
||||
if (!payload) return;
|
||||
const room = getBodyshopRoom(socket.bodyshopId);
|
||||
io.to(room).emit("bodyshop-message", { type: "task-created", payload });
|
||||
});
|
||||
|
||||
socket.on("task-updated", (payload) => {
|
||||
if (!payload) return;
|
||||
const room = getBodyshopRoom(socket.bodyshopId);
|
||||
io.to(room).emit("bodyshop-message", { type: "task-updated", payload });
|
||||
});
|
||||
|
||||
socket.on("task-deleted", (payload) => {
|
||||
if (!payload || !payload.id) return;
|
||||
const room = getBodyshopRoom(socket.bodyshopId);
|
||||
io.to(room).emit("bodyshop-message", { type: "task-deleted", payload });
|
||||
});
|
||||
};
|
||||
|
||||
// Call Handlers
|
||||
registerRoomAndBroadcastEvents(socket);
|
||||
registerUpdateEvents(socket);
|
||||
registerMessagingEvents(socket);
|
||||
registerDisconnectEvents(socket);
|
||||
registerSyncEvents(socket);
|
||||
registerTaskEvents(socket);
|
||||
registerFortellisEvents(socket);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user