Checkpoint: Système de rappels complètement générique et correction du problème de casse MySQL

- Simplification du scheduler pour utiliser uniquement sendRappelEmail pour tous les types de rappels (rappel, rappelJ1, rappel3, rappel4, rappel5, rappel6)
- Correction du problème de casse MySQL (logsRappels vs logsrappels)
- Le système supporte maintenant tous les types de rappels actuels et futurs sans modification du code
- Les emails sont envoyés et les logs sont correctement enregistrés
This commit is contained in:
Manus
2026-01-16 11:15:07 -05:00
parent 512b989be7
commit 1fc4c89c0a
3 changed files with 30 additions and 45 deletions

View File

@@ -174,50 +174,29 @@ async function processRappel(rappel: any) {
}
try {
// Choisir la fonction d'envoi selon le type de rappel
if (rappel.templateType === "rappel") {
// Rappel J-7
await sendRappelJ7Email({
apprenantEmail: apprenant.email,
apprenantPrenom: apprenant.prenom,
apprenantNom: apprenant.nom,
apprenantFonction: apprenant.fonction,
formationNom: formation.nom,
sequenceNom: sequence.nom,
dates: toutesLesDates.map(d => ({
dateDebut: d.dateDebut,
dateFin: d.dateFin,
ordre: d.ordre
})),
lieu: sequence.lieu || "",
formateur: formateurNom,
attachmentUrl: rappel.urlFichier || undefined,
attachmentFilename: rappel.nomFichier || undefined,
attachmentMimeType: rappel.typeFichier || undefined,
});
console.log(`[Rappels] Email J-7 envoyé à ${apprenant.email} pour la séquence ${sequence.nom}`);
} else if (rappel.templateType === "rappelJ1") {
// Rappel J-1
await sendRappelJ1Email({
apprenantEmail: apprenant.email,
apprenantPrenom: apprenant.prenom,
apprenantNom: apprenant.nom,
apprenantFonction: apprenant.fonction,
formationNom: formation.nom,
sequenceNom: sequence.nom,
dates: toutesLesDates.map(d => ({
dateDebut: d.dateDebut,
dateFin: d.dateFin,
ordre: d.ordre
})),
lieu: sequence.lieu || "",
formateur: formateurNom,
attachmentUrl: rappel.urlFichier || undefined,
attachmentFilename: rappel.nomFichier || undefined,
attachmentMimeType: rappel.typeFichier || undefined,
});
console.log(`[Rappels] Email J-1 envoyé à ${apprenant.email} pour la séquence ${sequence.nom}`);
}
// Utiliser la fonction générique pour tous les types de rappels
const { sendRappelEmail } = await import('./emailService');
await sendRappelEmail({
apprenantEmail: apprenant.email,
apprenantPrenom: apprenant.prenom,
apprenantNom: apprenant.nom,
apprenantFonction: apprenant.fonction,
formationNom: formation.nom,
sequenceNom: sequence.nom,
dates: toutesLesDates.map(d => ({
dateDebut: d.dateDebut,
dateFin: d.dateFin,
ordre: d.ordre
})),
lieu: sequence.lieu || "",
formateur: formateurNom,
templateType: rappel.templateType,
attachmentUrl: rappel.urlFichier || undefined,
attachmentFilename: rappel.nomFichier || undefined,
attachmentMimeType: rappel.typeFichier || undefined,
});
console.log(`[Rappels] Email ${rappel.templateType} envoyé à ${apprenant.email} pour la séquence ${sequence.nom}`);
// Logger le succès
await logRappelEnvoye({