feature/IO-3000-messaging-sockets-migrations2 -

- Conversation Labels Synced
- Job Tagging Synced

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-11-20 18:22:27 -08:00
parent 250faa672f
commit 06afd6da5b
9 changed files with 142 additions and 75 deletions

View File

@@ -145,7 +145,6 @@ const redisSocketEvents = ({
error: error.message,
stack: error.stack
});
socket.emit("error", { message: "Failed to join conversation" });
}
};
const leaveConversationRoom = ({ bodyshopId, conversationId }) => {
@@ -162,6 +161,24 @@ const redisSocketEvents = ({
}
};
const conversationModified = ({ bodyshopId, conversationId, ...fields }) => {
try {
// Retrieve the room name for the conversation
const room = getBodyshopConversationRoom({ bodyshopId, conversationId });
// Emit the updated data to all clients in the room
io.to(room).emit("conversation-changed", {
conversationId,
...fields
});
} catch (error) {
logger.log("Failed to handle conversation modification", "error", "io-redis", null, {
error: error.message,
stack: error.stack
});
}
};
socket.on("conversation-modified", conversationModified);
socket.on("join-bodyshop-conversation", joinConversationRoom);
socket.on("leave-bodyshop-conversation", leaveConversationRoom);
};