feature/IO-3000-messaging-sockets-migrations2 - Base cleanup
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -1,12 +1,4 @@
|
||||
const { admin } = require("../firebase/firebase-handler");
|
||||
const { MARK_MESSAGES_AS_READ, GET_CONVERSATIONS, GET_CONVERSATION_DETAILS } = require("../graphql-client/queries");
|
||||
const { phone } = require("phone");
|
||||
const { client: gqlClient } = require("../graphql-client/graphql-client");
|
||||
const queries = require("../graphql-client/queries");
|
||||
const twilio = require("twilio");
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
|
||||
const twilioClient = twilio(process.env.TWILIO_AUTH_TOKEN, process.env.TWILIO_AUTH_KEY);
|
||||
|
||||
const redisSocketEvents = ({
|
||||
io,
|
||||
@@ -84,6 +76,7 @@ const redisSocketEvents = ({
|
||||
};
|
||||
socket.on("update-token", updateToken);
|
||||
};
|
||||
|
||||
// Room Broadcast Events
|
||||
const registerRoomAndBroadcastEvents = (socket) => {
|
||||
const joinBodyshopRoom = (bodyshopUUID) => {
|
||||
@@ -138,6 +131,7 @@ const redisSocketEvents = ({
|
||||
|
||||
socket.on("disconnect", disconnect);
|
||||
};
|
||||
|
||||
// Messaging Events
|
||||
const registerMessagingEvents = (socket) => {
|
||||
const joinConversationRoom = async ({ bodyshopId, conversationId }) => {
|
||||
@@ -145,19 +139,26 @@ const redisSocketEvents = ({
|
||||
const room = getBodyshopConversationRoom({ bodyshopId, conversationId });
|
||||
socket.join(room);
|
||||
} catch (error) {
|
||||
logger.log("error", "Failed to join conversation", error);
|
||||
logger.log("Failed to Join Conversation Room", "error", "io-redis", null, {
|
||||
bodyshopId,
|
||||
conversationId,
|
||||
error: error.message,
|
||||
stack: error.stack
|
||||
});
|
||||
socket.emit("error", { message: "Failed to join conversation" });
|
||||
}
|
||||
};
|
||||
|
||||
const leaveConversationRoom = ({ bodyshopId, conversationId }) => {
|
||||
try {
|
||||
const room = getBodyshopConversationRoom({ bodyshopId, conversationId });
|
||||
socket.leave(room);
|
||||
// Optionally notify the client
|
||||
//socket.emit("conversation-left", { conversationId });
|
||||
} catch (error) {
|
||||
socket.emit("error", { message: "Failed to leave conversation" });
|
||||
logger.log("Failed to Leave Conversation Room", "error", "io-redis", null, {
|
||||
bodyshopId,
|
||||
conversationId,
|
||||
error: error.message,
|
||||
stack: error.stack
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user