Update notification.processor.service.ts

This commit is contained in:
Baobhan Sith
2025-04-26 22:10:07 +08:00
parent eb9ed10f19
commit 95fac7981c
@@ -215,29 +215,12 @@ class NotificationProcessorService extends EventEmitter {
// Use user-defined template first, then the GENERIC fallback // Use user-defined template first, then the GENERIC fallback
switch (setting.channel_type) { switch (setting.channel_type) {
case 'email': case 'email':
console.log(`[NotificationProcessor NEW DEBUG] Raw setting.config:`, JSON.stringify(setting.config));
console.log(`[NotificationProcessor NEW DEBUG] Parsed emailConfig:`, JSON.stringify(emailConfig));
if (emailConfig && typeof emailConfig === 'object') {
console.log(`[NotificationProcessor NEW DEBUG] emailConfig.subjectTemplate:`, emailConfig.subjectTemplate);
} else {
console.log(`[NotificationProcessor NEW DEBUG] emailConfig is not a valid object.`);
}
const emailConfig = setting.config as EmailConfig; const emailConfig = setting.config as EmailConfig;
// Subject is now fixed to the translated event name // Subject is now fixed to the translated event name
if (emailConfig && typeof emailConfig === 'object') {
console.log(`[NotificationProcessor NEW DEBUG] emailConfig.subjectTemplate:`, emailConfig.subjectTemplate);
} else {
console.log(`[NotificationProcessor NEW DEBUG] emailConfig is not a valid object.`);
}
subject = translatedEvent; subject = translatedEvent;
// Use user-defined template (from subjectTemplate field) for the BODY, or generic fallback // Use user-defined template (from bodyTemplate field) for the BODY, or generic fallback
const bodyTemplate = emailConfig?.bodyTemplate || genericEmailBody; // Use optional chaining and correct property
const bodyTemplate = emailConfig.subjectTemplate || genericEmailBody;
body = this.interpolate(bodyTemplate, baseInterpolationData); body = this.interpolate(bodyTemplate, baseInterpolationData);
break; break;