feature/IO-3000-Migrate-MSG-to-Sockets - Progress Checkpoint
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -140,11 +140,6 @@ const redisSocketEvents = ({
|
||||
};
|
||||
// Messaging Events
|
||||
const registerMessagingEvents = (socket) => {
|
||||
const broadcastNewMessage = async (message) => {
|
||||
const room = `conversation-${message.conversationId}`;
|
||||
io.to(room).emit("new-message", message);
|
||||
};
|
||||
|
||||
const openMessaging = async (bodyshopUUID) => {
|
||||
try {
|
||||
const conversations = await client.request(GET_CONVERSATIONS, { bodyshopId: bodyshopUUID });
|
||||
@@ -282,6 +277,19 @@ const redisSocketEvents = ({
|
||||
}
|
||||
};
|
||||
|
||||
const leaveConversation = (conversationId) => {
|
||||
try {
|
||||
const room = `conversation-${conversationId}`;
|
||||
socket.leave(room);
|
||||
|
||||
// Optionally notify the client
|
||||
socket.emit("conversation-left", { conversationId });
|
||||
} catch (error) {
|
||||
socket.emit("error", { message: "Failed to leave conversation" });
|
||||
}
|
||||
};
|
||||
|
||||
socket.on("leave-conversation", leaveConversation);
|
||||
socket.on("send-message", sendMessage);
|
||||
socket.on("mark-as-read", markAsRead);
|
||||
socket.on("join-conversation", joinConversation);
|
||||
|
||||
Reference in New Issue
Block a user