farewell: дата, тумблер ИИ и готовый текст в модалке, прошлый отзыв тумблером
This commit is contained in:
@@ -6226,10 +6226,14 @@ app.post('/api/farewells', requireAuth, async (req, res) => {
|
||||
const row = await createFarewell(pool, {
|
||||
resident: req.body?.resident,
|
||||
topic: req.body?.topic,
|
||||
messageDate: req.body?.message_date,
|
||||
sourceFeedbackIds: req.body?.source_feedback_ids,
|
||||
templateId: req.body?.template_id,
|
||||
prompt: req.body?.prompt,
|
||||
aiProfile: req.body?.ai_profile,
|
||||
aiCheck: req.body?.ai_check,
|
||||
text: req.body?.text,
|
||||
pastReview: req.body?.past_review,
|
||||
authorId: req.user.id,
|
||||
isAdmin: req.user.role === 'admin',
|
||||
branchIds: bs.ids || null,
|
||||
@@ -6251,7 +6255,7 @@ app.post('/api/farewells/:id/ai/retry', requireAuth, async (req, res) => {
|
||||
if (!row) return res.status(404).json({ error: 'Not found' });
|
||||
if (req.user.role !== 'admin' && row.author_id !== req.user.id) return res.status(403).json({ error: 'Нет доступа' });
|
||||
if (row.deleted_at) return res.status(400).json({ error: 'Прощальное сообщение удалено' });
|
||||
await setFarewellStatus(pool, id, 'pending', { aiError: null });
|
||||
await setFarewellStatus(pool, id, 'pending', { aiError: null, clearPrompt: row.ai_status === 'error' });
|
||||
logAudit(req, 'farewell.ai.retry', { farewell_id: id });
|
||||
wakeFarewellWorker();
|
||||
res.json({ ok: true });
|
||||
@@ -8028,8 +8032,8 @@ app.post('/api/restore', requireAdmin, backupUploadGuard, uploadBackup.single('b
|
||||
const okUser = x.author_id == null || (await client.query('SELECT 1 FROM users WHERE id = $1', [x.author_id])).rowCount;
|
||||
const okTpl = x.template_id == null || x.template_id === x.id || (await client.query('SELECT 1 FROM farewell_messages WHERE id = $1', [x.template_id])).rowCount;
|
||||
await client.query(
|
||||
'INSERT INTO farewell_messages (id, resident, topic, source_feedback_ids, template_id, template_text, prompt, ai_profile, ai_status, text, ai_error, ai_prompt, ai_model, ai_duration_ms, author_id, sent_at, deleted_at, purge_at, created_at, updated_at) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,COALESCE($19, now()),COALESCE($20, now()))',
|
||||
[x.id, x.resident, x.topic, Array.isArray(x.source_feedback_ids) ? x.source_feedback_ids : [], okTpl ? x.template_id : null, x.template_text, x.prompt, x.ai_profile, x.ai_status || 'pending', x.text, x.ai_error, x.ai_prompt, x.ai_model, x.ai_duration_ms, okUser ? x.author_id : null, x.sent_at, x.deleted_at, x.purge_at, x.created_at, x.updated_at]
|
||||
'INSERT INTO farewell_messages (id, resident, topic, message_date, source_feedback_ids, template_id, template_text, prompt, ai_profile, ai_status, text, ai_error, ai_prompt, ai_model, ai_duration_ms, author_id, sent_at, deleted_at, purge_at, created_at, updated_at) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,COALESCE($20, now()),COALESCE($21, now()))',
|
||||
[x.id, x.resident, x.topic, x.message_date, Array.isArray(x.source_feedback_ids) ? x.source_feedback_ids : [], okTpl ? x.template_id : null, x.template_text, x.prompt, x.ai_profile, x.ai_status || 'pending', x.text, x.ai_error, x.ai_prompt, x.ai_model, x.ai_duration_ms, okUser ? x.author_id : null, x.sent_at, x.deleted_at, x.purge_at, x.created_at, x.updated_at]
|
||||
);
|
||||
}
|
||||
for (const x of ndata.audit_log) {
|
||||
|
||||
Reference in New Issue
Block a user