Fix backend 500 errors for event creation and system version

- Fix system version endpoint to read package.json using fs instead of require
  - Prevents MODULE_NOT_FOUND error in Docker container
  - Uses path.join to find package.json reliably

- Fix event creation email queue error
  - Change email_type from 'creation' to 'gallery_created' to match template key
  - Update email_data to include all required template variables
  - Added missing created_at and updated_at columns to email_queue table

- Fix file watcher duplicate photo insertion
  - Add check to prevent re-inserting existing photos on backend restart

These fixes resolve:
1. 500 error when accessing /api/admin/system/version
2. 500 error when creating new events
3. Email queue processing errors
4. Photo duplication issue

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-09 08:53:18 +02:00
parent ec3d5a0f80
commit 472445a2e5
2 changed files with 16 additions and 6 deletions
+6 -4
View File
@@ -99,12 +99,14 @@ router.post('/', adminAuth, [
await db('email_queue').insert({
event_id: eventId,
recipient_email: host_email,
email_type: 'creation',
email_type: 'gallery_created',
email_data: JSON.stringify({
host_name: host_email.split('@')[0], // Extract name from email
event_name,
share_link: shareLink,
password,
expires_at: expires_at.toISOString()
event_date: new Date(event_date).toLocaleDateString(),
gallery_link: shareLink,
gallery_password: password,
expiry_date: expires_at.toLocaleDateString()
})
// scheduled_at will use default value
});