fix: address code review feedback - add error handling and fix import style
Co-authored-by: ZimengXiong <83783148+ZimengXiong@users.noreply.github.com>
This commit is contained in:
committed by
Zimeng Xiong
parent
ef75f9ebdf
commit
94694deb91
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeAll, afterAll, beforeEach } from "vitest";
|
import { describe, it, expect, beforeAll, afterAll, beforeEach } from "vitest";
|
||||||
|
import bcrypt from "bcrypt";
|
||||||
import {
|
import {
|
||||||
getTestPrisma,
|
getTestPrisma,
|
||||||
cleanupTestDb,
|
cleanupTestDb,
|
||||||
@@ -28,7 +29,6 @@ describe("User Data Sandboxing", () => {
|
|||||||
prisma = getTestPrisma();
|
prisma = getTestPrisma();
|
||||||
|
|
||||||
// Create two test users
|
// Create two test users
|
||||||
const bcrypt = require("bcrypt");
|
|
||||||
const hashA = await bcrypt.hash("passwordA", 10);
|
const hashA = await bcrypt.hash("passwordA", 10);
|
||||||
const hashB = await bcrypt.hash("passwordB", 10);
|
const hashB = await bcrypt.hash("passwordB", 10);
|
||||||
|
|
||||||
|
|||||||
@@ -797,6 +797,7 @@ io.on("connection", (socket) => {
|
|||||||
drawingId: string;
|
drawingId: string;
|
||||||
user: Omit<User, "socketId" | "isActive">;
|
user: Omit<User, "socketId" | "isActive">;
|
||||||
}) => {
|
}) => {
|
||||||
|
try {
|
||||||
// Verify the authenticated user owns this drawing
|
// Verify the authenticated user owns this drawing
|
||||||
if (authenticatedUserId) {
|
if (authenticatedUserId) {
|
||||||
const drawing = await prisma.drawing.findFirst({
|
const drawing = await prisma.drawing.findFirst({
|
||||||
@@ -821,6 +822,10 @@ io.on("connection", (socket) => {
|
|||||||
roomUsers.set(roomId, filteredUsers);
|
roomUsers.set(roomId, filteredUsers);
|
||||||
|
|
||||||
io.to(roomId).emit("presence-update", filteredUsers);
|
io.to(roomId).emit("presence-update", filteredUsers);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error in join-room handler:", err);
|
||||||
|
socket.emit("error", { message: "Failed to join room" });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user