join room on initialize contact

This commit is contained in:
slawk0
2024-12-04 23:03:33 +01:00
parent 722e1cfde9
commit b9b925d612
7 changed files with 56 additions and 46 deletions

View File

@@ -62,14 +62,20 @@ function initializeSocket(io) {
return;
}
let conversations = [];
try {
const conversations = await getConversationsForUser(socket.user_id);
conversations = await getConversationsForUser(socket.user_id);
conversations.push(socket.user_id);
socket.join(conversations);
} catch (e) {
console.error("(socket) Failed to get user conversations");
}
socket.on("join room", (msg) => {
console.log("Join room for: ", username, "room: ", msg);
socket.join(msg);
});
socket.on("chat message", async (msg, callback) => {
const { message, recipient, recipient_id, attachment_urls } = msg;
const sender = socket.username;