diff --git a/backend/migrations/core/047_add_video_support.js b/backend/migrations/core/048_add_video_support.js similarity index 100% rename from backend/migrations/core/047_add_video_support.js rename to backend/migrations/core/048_add_video_support.js diff --git a/backend/server.js b/backend/server.js index cdc345c..fa6d133 100644 --- a/backend/server.js +++ b/backend/server.js @@ -324,9 +324,9 @@ async function initializeRateLimiters() { // Note: Rate limiters will be initialized after database connection -// Body parsing middleware with increased limits for large batch uploads -app.use(express.json({ limit: '500mb' })); -app.use(express.urlencoded({ extended: true, limit: '500mb' })); +<<<<<<< HEAD +app.use(express.json({ limit: '10gb' })); +app.use(express.urlencoded({ extended: true, limit: '10gb' })); // Request logging for API routes (with timestamps) const apiRequestLogger = (req, res, next) => { diff --git a/backend/src/routes/adminPhotos.js b/backend/src/routes/adminPhotos.js index 769e27f..84a8320 100644 --- a/backend/src/routes/adminPhotos.js +++ b/backend/src/routes/adminPhotos.js @@ -499,14 +499,22 @@ router.patch('/:eventId/photos/:photoId', adminAuth, async (req, res) => { if (category_id === 'individual' || category_id === 'collage') { updateData.type = category_id; updateData.category_id = null; // Clear legacy category_id + } else if (category_id === null || category_id === undefined) { + // Explicitly clear category + updateData.category_id = null; } else { - // Handle legacy numeric category IDs - updateData.category_id = category_id || null; + // Handle numeric category IDs from photo_categories table + const numericCategoryId = parseInt(category_id, 10); + if (!isNaN(numericCategoryId)) { + updateData.category_id = numericCategoryId; + } else { + updateData.category_id = null; + } } // Update photo await db('photos') - .where({ id: photoId }) + .where({ id: photoId, event_id: eventId }) .update(updateData); res.json({ message: 'Photo updated successfully' }); @@ -601,21 +609,32 @@ router.post('/:eventId/photos/bulk-update', adminAuth, async (req, res) => { .count('id as count') .first(); - if (photoCount.count !== photoIds.length) { + if (parseInt(photoCount.count) !== photoIds.length) { return res.status(400).json({ error: 'Some photos do not belong to this event' }); } // Prepare update data - const updateData = {}; + const updateData = { + updated_at: new Date() + }; + if (updates.category_id !== undefined) { // Handle type-based categories ('individual' or 'collage') // These are string values that map to the photo.type field if (updates.category_id === 'individual' || updates.category_id === 'collage') { updateData.type = updates.category_id; updateData.category_id = null; // Clear legacy category_id + } else if (updates.category_id === null) { + // Explicitly clear category + updateData.category_id = null; } else { - // Handle legacy numeric category IDs - updateData.category_id = updates.category_id || null; + // Handle numeric category IDs from photo_categories table + const numericCategoryId = parseInt(updates.category_id, 10); + if (!isNaN(numericCategoryId)) { + updateData.category_id = numericCategoryId; + } else { + updateData.category_id = null; + } } }