feature/IO-3000-messaging-sockets-migrations2 -
- sync send - fix status events Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -36,7 +36,9 @@ exports.status = async (req, res) => {
|
||||
});
|
||||
|
||||
ioRedis.to(conversationRoom).emit("message-changed", {
|
||||
message
|
||||
...message,
|
||||
status: SmsStatus,
|
||||
type: "status-changed"
|
||||
});
|
||||
} else {
|
||||
logger.log("sms-status-update-warning", "WARN", "api", null, {
|
||||
@@ -80,21 +82,11 @@ exports.markConversationRead = async (req, res) => {
|
||||
|
||||
const broadcastRoom = getBodyshopRoom(bodyshopid);
|
||||
|
||||
const conversationRoom = getBodyshopConversationRoom({
|
||||
bodyshopId: bodyshopid,
|
||||
conversationId: conversationid
|
||||
});
|
||||
|
||||
ioRedis.to(broadcastRoom).emit("conversation-changed", {
|
||||
type: "conversation-marked-read",
|
||||
conversationId: conversationid
|
||||
});
|
||||
|
||||
ioRedis.to(conversationRoom).emit("message-changed", {
|
||||
type: "all-messages-marked-read",
|
||||
conversationId: conversationid
|
||||
});
|
||||
|
||||
res.status(200).json({ success: true, message: "Conversation marked as read." });
|
||||
} catch (error) {
|
||||
logger.log("conversation-mark-read-error", "ERROR", "api", null, {
|
||||
|
||||
@@ -178,6 +178,19 @@ const redisSocketEvents = ({
|
||||
}
|
||||
};
|
||||
|
||||
const messageAdded = ({ bodyshopId, conversationId, message }) => {
|
||||
try {
|
||||
const room = getBodyshopConversationRoom({ bodyshopId, conversationId });
|
||||
io.to(room).emit("new-message", message);
|
||||
} catch (error) {
|
||||
logger.log("Failed to handle new message", "error", "io-redis", null, {
|
||||
error: error.message,
|
||||
stack: error.stack
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
socket.on("message-added", messageAdded);
|
||||
socket.on("conversation-modified", conversationModified);
|
||||
socket.on("join-bodyshop-conversation", joinConversationRoom);
|
||||
socket.on("leave-bodyshop-conversation", leaveConversationRoom);
|
||||
|
||||
Reference in New Issue
Block a user