feat: Implement comprehensive email notifications system

This commit implements a complete email notifications system for purchase
confirmations and event reminders as requested in the medium priority
backlog tasks.

## Features Added

### Purchase Confirmation Emails
- Automatically sent when orders are marked as paid
- Supports both single tickets and multi-ticket orders
- Includes PDF ticket attachments
- Professional HTML and text templates in French

### Event Reminder Emails
- Automated reminders sent 7 days, 1 day, and day of events
- Only sent to users with active tickets
- Smart messaging based on time until event
- Venue details and ticket information included

### Background Jobs
- EventReminderJob: Sends reminders to all users for a specific event
- EventReminderSchedulerJob: Daily scheduler to queue reminder jobs
- Proper error handling and logging

### Email Templates
- Responsive HTML templates with ApéroNight branding
- Text fallbacks for better email client compatibility
- Dynamic content based on number of tickets and time until event

### Configuration & Testing
- Environment-based SMTP configuration for production
- Development setup with MailCatcher support
- Comprehensive test suite with mocking for PDF generation
- Integration tests for end-to-end functionality
- Documentation with usage examples

## Technical Implementation
- Enhanced TicketMailer with new notification methods
- Background job scheduling via Rails initializer
- Order model integration for automatic purchase confirmations
- Proper associations handling for user/ticket relationships
- Configurable via environment variables

## Files Added/Modified
- Enhanced app/mailers/ticket_mailer.rb with order support
- Added app/jobs/event_reminder_*.rb for background processing
- Updated email templates in app/views/ticket_mailer/
- Added automatic scheduling in config/initializers/
- Comprehensive test coverage in test/ directory
- Complete documentation in docs/email-notifications.md

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
kbe
2025-09-06 13:25:02 +02:00
parent 73eefdd7bd
commit 7f36abbcec
17 changed files with 854 additions and 26 deletions

View File

@@ -0,0 +1,41 @@
Salut <%= @user.email.split('@').first %> !
<% case @days_before %>
<% when 7 %>
Plus qu'une semaine avant "<%= @event.name %>" !
<% when 1 %>
C'est demain ! "<%= @event.name %>" a lieu demain.
<% when 0 %>
C'est aujourd'hui ! "<%= @event.name %>" a lieu aujourd'hui.
<% else %>
Plus que <%= @days_before %> jours avant "<%= @event.name %>" !
<% end %>
DÉTAILS DE L'ÉVÉNEMENT
======================
Date & heure : <%= @event.start_time.strftime("%d %B %Y à %H:%M") %>
Lieu : <%= @event.venue_name %>
Adresse : <%= @event.venue_address %>
VOS BILLETS POUR CET ÉVÉNEMENT :
<% @tickets.each_with_index do |ticket, index| %>
- Billet #<%= index + 1 %> : <%= ticket.ticket_type.name %> (ACTIF)
<% end %>
<% if @days_before == 0 %>
N'oubliez pas vos billets ! Ils ont été envoyés par email lors de votre achat.
<% else %>
Vos billets ont été envoyés par email lors de votre achat.
<% end %>
Présentez-les à l'entrée de l'événement pour y accéder.
<% if @days_before <= 1 %>
Conseil : Arrivez un peu en avance pour éviter les files d'attente à l'entrée !
<% else %>
N'oubliez pas d'ajouter cet événement à votre calendrier pour ne pas le manquer !
<% end %>
Des questions ? Contactez-nous à support@aperonight.com
© <%= Time.current.year %> ApéroNight. Tous droits réservés.