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:
@@ -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}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user