Skip to content

Commit e86d7f2

Browse files
committed
Adding a pending flag and cancellation endpoint
1 parent e433641 commit e86d7f2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

backend/matching/src/controllers/cancel-request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const cancelMatchRequestController = async (req: Request, res: Response)
2424
}
2525

2626
const pendingStatus = await redisClient.hGet(`match:${userId}`, 'pending');
27-
console.log(pendingStatus);
27+
console.log('this is pendingStatus ${pendingStatus}');
2828
const data = await redisClient.hGetAll(`match:${userId}`);
2929
console.log(`Data stored in Redis for user ${userId}:`, data);
3030

backend/matching/src/workers/matcher.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ async function match() {
210210
if (!hasDifficultyMatch) {
211211
// To allow cancellation
212212
sendNotif([requestorSocketPort], MATCHING_EVENT.PENDING);
213+
214+
const setPendingToTrue = async (userId: string) => {
215+
await redisClient.hSet(`match:${userId}`, 'pending', 'true');
216+
console.log(`User ${userId} is now in PENDING state, pending set to true.`);
217+
};
218+
219+
await setPendingToTrue(requestorUserId);
213220
}
214221
}
215222
}

0 commit comments

Comments
 (0)