Mail schemes updated auto system

This commit is contained in:
salvacybersec
2025-11-11 03:02:11 +03:00
parent a8bedc7fbc
commit 06136294da
4 changed files with 358 additions and 63 deletions

View File

@@ -2,6 +2,25 @@ const ollamaService = require('../services/ollama.service');
const { Settings, MailTemplate } = require('../models');
const logger = require('../utils/logger');
/**
* Get available template themes
*/
exports.getThemes = async (req, res, next) => {
try {
const themes = ollamaService.getAvailableThemes();
res.json({
success: true,
data: {
themes,
},
});
} catch (error) {
logger.error('Failed to get themes:', error);
next(error);
}
};
/**
* Test Ollama connection
*/
@@ -96,7 +115,7 @@ exports.updateSettings = async (req, res, next) => {
*/
exports.generateTemplate = async (req, res, next) => {
try {
const { company_name, scenario, employee_info, custom_prompt, template_name, template_type } = req.body;
const { company_name, scenario, employee_info, custom_prompt, template_name, template_type, generate_html, template_theme } = req.body;
// Validation
if (!company_name || !scenario) {
@@ -106,7 +125,7 @@ exports.generateTemplate = async (req, res, next) => {
});
}
logger.info(`AI template generation requested for: ${company_name} - ${scenario}`);
logger.info(`AI template generation requested for: ${company_name} - ${scenario} (HTML: ${generate_html ? 'yes' : 'no'}, Theme: ${template_theme || 'red'})`);
// Generate template using Ollama
const templateData = await ollamaService.generateMailTemplate({
@@ -114,6 +133,8 @@ exports.generateTemplate = async (req, res, next) => {
scenario,
employee_info,
custom_prompt,
generate_html: generate_html || false,
template_theme: template_theme || 'red',
});
// Save to database if template_name is provided