Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/controllers/eventController.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,10 @@ const autoPromoteFromWaitlist = (event) => {

while (event.currentAttendees < event.maxAttendees && event.waitlist.length > 0) {
const nextEntry = event.waitlist.shift();

if (!nextEntry?.userId) continue;
console.log(`Auto-promoting user from waitlist for event ${event._id}`);
event.currentAttendees += 1;
promotedUsers.push(nextEntry.userId);
if (nextEntry?.userId) {
event.currentAttendees += 1;
promotedUsers.push(nextEntry.userId);
}
}

return promotedUsers;
Expand Down Expand Up @@ -265,7 +264,6 @@ const joinWaitlist = async (req, res) => {
try {
const { eventId } = req.params;
const { userId } = req.body;
console.log('Join waitlist request received');

if (!userId || !mongoose.Types.ObjectId.isValid(userId)) {
return res.status(400).json({ error: 'Invalid userId' });
Expand Down Expand Up @@ -294,7 +292,6 @@ const joinWaitlist = async (req, res) => {
position,
});
} catch (error) {
console.error('JOIN WAITLIST ERROR:', error);
res.status(500).json({
error: 'Failed to join waitlist',
details: error.message,
Expand All @@ -304,7 +301,6 @@ const joinWaitlist = async (req, res) => {

const sendWaitlistNotification = async (user, event) => {
// TODO: Integrate with real notification service (email/queue)
console.log(`Sending waitlist notification for event ${event._id}`);
};

const leaveEvent = async (req, res) => {
Expand Down
Loading