feat: add resend creation email button and fix Handlebars template processing
Mirror to GitHub / mirror (push) Successful in 21s
Test and Lint / backend-test (push) Successful in 1m6s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m7s
Version and Release / version-bump (push) Successful in 41s
Version and Release / trigger-drone (push) Successful in 3s

- Fixed email template processing to properly handle Handlebars conditionals
  - Installed handlebars package
  - Updated processTemplate to use Handlebars.compile()
  - Now {{#if welcome_message}} blocks work correctly

- Added "Resend Creation Email" button to event details page
  - New endpoint: POST /api/admin/events/:id/resend-email
  - Button appears below "Reset Gallery Password"
  - Shows mail icon and includes success/error notifications
  - For security, resent emails show "(Aus Sicherheitsgründen nicht angezeigt)"
    instead of the actual password

- Added translations:
  - EN: "Resend Creation Email", success/error messages
  - DE: "Erstellungs-E-Mail erneut senden", success/error messages

This fixes the issue where Handlebars syntax was showing in emails and provides
a convenient way to resend the initial gallery creation email to hosts.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-16 16:24:33 +02:00
parent 1b075a4beb
commit 419a283c62
8 changed files with 140 additions and 24 deletions
+51
View File
@@ -564,6 +564,57 @@ router.post('/:id/reset-password', adminAuth, async (req, res) => {
}
});
// Resend creation email
router.post('/:id/resend-email', adminAuth, async (req, res) => {
try {
const { id } = req.params;
// Get event details
const event = await db('events')
.where('id', id)
.first();
if (!event) {
return res.status(404).json({ error: 'Event not found' });
}
// Format dates properly for the email
const eventDate = new Date(event.event_date);
const expiryDate = new Date(event.expires_at);
// Queue the email
const { queueEmail } = require('../services/emailProcessor');
await queueEmail(id, event.host_email, 'gallery_created', {
host_name: event.host_name || event.host_email.split('@')[0],
event_name: event.event_name,
event_date: eventDate.toLocaleDateString('de-DE'), // Using German date format
gallery_link: event.share_link,
gallery_password: '(Aus Sicherheitsgründen nicht angezeigt)', // Security: don't show password in resent emails
expiry_date: expiryDate.toLocaleDateString('de-DE'),
welcome_message: event.welcome_message || '',
eventId: id
});
// Log the activity
await db('activity_logs').insert({
event_id: id,
ip_address: req.ip,
user_agent: req.get('user-agent'),
action_type: 'email_resent',
action_details: JSON.stringify({ email_type: 'gallery_created' }),
timestamp: new Date()
});
res.json({
success: true,
message: 'Creation email has been queued for sending'
});
} catch (error) {
console.error('Error resending creation email:', error);
res.status(500).json({ error: 'Failed to resend creation email' });
}
});
// Archive event
router.post('/:id/archive', adminAuth, async (req, res) => {
try {