diff --git a/backend/matching-service/models/RoomSchema.ts b/backend/matching-service/models/RoomSchema.ts index 9d78e2b817..440a2b43a1 100644 --- a/backend/matching-service/models/RoomSchema.ts +++ b/backend/matching-service/models/RoomSchema.ts @@ -12,7 +12,7 @@ export interface Room extends mongoose.Document { const roomSchema: Schema = new mongoose.Schema({ - participants: [{ userId: String }], + participants: [{ type: String }], category: { type: String, default: 'Any' }, difficulty: { type: String, default: 'Any' }, roomId: { type: String, required: true }, diff --git a/backend/matching-service/workers/matchWorker.ts b/backend/matching-service/workers/matchWorker.ts index 4904c80944..e20e643016 100644 --- a/backend/matching-service/workers/matchWorker.ts +++ b/backend/matching-service/workers/matchWorker.ts @@ -399,15 +399,14 @@ export async function emitMatchEvent(matchId: string) { if (roomObject.questionId && roomObject.roomId) { const newRoom = new Room({ participants: [ - { userId: roomObject.user1.userId }, - { userId: roomObject.user2.userId }, + JSON.parse(roomObject.user1).userId, + JSON.parse(roomObject.user2).userId, ], category: roomObject.category, difficulty: roomObject.difficulty, roomId: roomObject.roomId, questionId: roomObject.questionId, }); - await newRoom.save(); await redisClient.xAdd("match_events", "*", { data }); diff --git a/frontend/src/domain/entities/Room.ts b/frontend/src/domain/entities/Room.ts index 15cbba4ea3..84bac1cd15 100644 --- a/frontend/src/domain/entities/Room.ts +++ b/frontend/src/domain/entities/Room.ts @@ -1,7 +1,7 @@ export interface Room { roomId: string; attemptStartedAt: string; - userIdOne: { _id: string }; - userIdTwo: { _id: string }; + userIdOne: string; + userIdTwo: string; questionId: string; } diff --git a/frontend/src/presentation/pages/room/CollaborationRoomPage.tsx b/frontend/src/presentation/pages/room/CollaborationRoomPage.tsx index 12188d33dd..dd8b287533 100644 --- a/frontend/src/presentation/pages/room/CollaborationRoomPage.tsx +++ b/frontend/src/presentation/pages/room/CollaborationRoomPage.tsx @@ -44,16 +44,17 @@ const CollaborationRoomPage: React.FC = () => { setRoom({ roomId: roomId, attemptStartedAt: attemptStartedAt, - userIdOne: { _id: user!._id }, - userIdTwo: { _id: matchUserId }, + userIdOne: user!._id, + userIdTwo: matchUserId, questionId: questionId }); } else { if (!urlRoomId) return; // Fetch room details from API const fetchedRoom = await roomUseCases.getRoomDetails(urlRoomId); + console.log("Fetched Room", fetchedRoom) // Ensure the current user is userIdOne - if (fetchedRoom.userIdOne._id !== user?._id) { + if (fetchedRoom.userIdOne !== user!._id) { const temp = fetchedRoom.userIdOne; fetchedRoom.userIdOne = fetchedRoom.userIdTwo; fetchedRoom.userIdTwo = temp; @@ -132,14 +133,16 @@ const CollaborationRoomPage: React.FC = () => {
-
- -
+ {room.questionId && room.roomId && room.attemptStartedAt && room.userIdTwo && +
+ +
+ }