fix: Correct database field names in Ollama template creation

The bug was in field mapping when saving AI-generated templates:
- Changed 'type' to 'template_type' (correct column name)
- Changed 'body_template' to 'body_html' (correct column name)

This fixes the 400 Bad Request validation error:
'notNull Violation: MailTemplate.template_type cannot be null'

Now AI template generation works correctly.
This commit is contained in:
salvacybersec
2025-11-10 23:45:38 +03:00
parent 1b3d6f263f
commit 69702c4700

View File

@@ -121,9 +121,9 @@ exports.generateTemplate = async (req, res, next) => {
if (template_name && template_type) { if (template_name && template_type) {
savedTemplate = await MailTemplate.create({ savedTemplate = await MailTemplate.create({
name: template_name, name: template_name,
type: template_type, template_type: template_type, // Fixed: was 'type', should be 'template_type'
subject_template: templateData.subject_template, subject_template: templateData.subject_template,
body_template: templateData.body_template, body_html: templateData.body_template, // Fixed: was 'body_template', should be 'body_html'
description: `AI tarafından oluşturuldu - ${scenario}`, description: `AI tarafından oluşturuldu - ${scenario}`,
}); });