Skip to content

Commit

Permalink
Fix forfeit not retrieving snapshot (CS3219-AY2425S1#95)
Browse files Browse the repository at this point in the history
* Fix forfeit not retrieving snapshot

* oops
  • Loading branch information
samuelim01 authored Nov 13, 2024
1 parent 3164014 commit a3e960e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion services/collaboration/src/controllers/roomController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const closeRoomController = async (req: Request, res: Response) => {
export const updateUserStatusInRoomController = async (req: Request, res: Response) => {
const userId = req.user.id;
const { roomId } = req.params;
const { isForfeit, snapshot } = req.body;
const { isForfeit } = req.body;

// Validate that isForfeit is a boolean value
if (typeof isForfeit !== 'boolean') {
Expand All @@ -140,6 +140,9 @@ export const updateUserStatusInRoomController = async (req: Request, res: Respon
return handleHttpNotFound(res, 'User not found in room');
}

// Obtain code and language
const snapshot = await retrieveSnapshot(roomId);

// Record the forfeited status in the user's history
await produceUpdateHistory(roomId, userId, HistoryStatus.FORFEITED, snapshot);

Expand Down

0 comments on commit a3e960e

Please sign in to comment.