bugfix
This commit is contained in:
@@ -185,6 +185,24 @@ router.post('/:id/invite', authMiddleware, asyncHandler(async (req, res) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ invited: invitedUsers.length });
|
||||
}));
|
||||
|
||||
// Accept/reject challenge invitation
|
||||
router.post('/:id/respond', authMiddleware, asyncHandler(async (req, res) => {
|
||||
const challengeId = req.params.id;
|
||||
const { status } = req.body; // 'accepted' or 'rejected'
|
||||
|
||||
if (!['accepted', 'rejected'].includes(status)) {
|
||||
throw new AppError('Invalid status', 400);
|
||||
}
|
||||
|
||||
await query(
|
||||
'UPDATE challenge_participants SET status = ?, responded_at = NOW() WHERE challenge_id = ? AND user_id = ?',
|
||||
[status, challengeId, req.user.userId]
|
||||
);
|
||||
|
||||
// Emit real-time event to challenge participants
|
||||
socketEvents.challengeInvitationResponse(challengeId, {
|
||||
user_id: req.user.userId,
|
||||
|
||||
Reference in New Issue
Block a user