fix: corretta ora di creazione dei ticket che non considerava il fusorario.

This commit is contained in:
2026-07-29 22:59:27 +02:00
parent e2482159bc
commit 57175922c2
+14 -11
View File
@@ -530,6 +530,8 @@ router.post('/', async (req, res) => {
// Operator user for create_by (X-Agent-ID header or default to 1) // Operator user for create_by (X-Agent-ID header or default to 1)
const operatorId = parseInt(req.headers['x-agent-id'], 10) || 1; const operatorId = parseInt(req.headers['x-agent-id'], 10) || 1;
const localNow = getLocalTimestamp();
const ticketResult = await client.query( const ticketResult = await client.query(
`INSERT INTO ticket ( `INSERT INTO ticket (
tn, title, queue_id, ticket_lock_id, type_id, tn, title, queue_id, ticket_lock_id, type_id,
@@ -550,14 +552,14 @@ router.post('/', async (req, res) => {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0,
NOW(), $12, NOW(), $12 $12, $13, $12, $13
) RETURNING id, tn`, ) RETURNING id, tn`,
[ [
tn, title, queue_id, lockId, type_id || null, tn, title, queue_id, lockId, type_id || null,
user_id || 1, responsibleUserId, user_id || 1, responsibleUserId,
priority_id, state_id, priority_id, state_id,
customer_id || null, customer_user_id || null, customer_id || null, customer_user_id || null,
operatorId localNow, operatorId
] ]
); );
@@ -578,13 +580,13 @@ router.post('/', async (req, res) => {
) VALUES ( ) VALUES (
$1, $2, $3, $4, $5, $1, $2, $3, $4, $5,
$6, $7, $8, $6, $7, $8,
NOW(), $9, NOW(), $9 $9, $10, $9, $10
)`, )`,
[ [
`%%`, `%%`,
historyTypeId, ticketId, type_id || 1, queue_id, historyTypeId, ticketId, type_id || 1, queue_id,
user_id || 1, priority_id, state_id, user_id || 1, priority_id, state_id,
operatorId localNow, operatorId
] ]
); );
@@ -643,9 +645,9 @@ router.post('/', async (req, res) => {
is_visible_for_customer, search_index_needs_rebuild, is_visible_for_customer, search_index_needs_rebuild,
create_time, create_by, change_time, change_by create_time, create_by, change_time, change_by
) VALUES ( ) VALUES (
$1, $2, $3, 0, 1, NOW(), $4, NOW(), $4 $1, $2, $3, 0, 1, $4, $5, $4, $5
) RETURNING id`, ) RETURNING id`,
[ticketId, senderTypeId, channelId, operatorId] [ticketId, senderTypeId, channelId, localNow, operatorId]
); );
const articleId = articleResult.rows[0].id; const articleId = articleResult.rows[0].id;
@@ -660,9 +662,9 @@ router.post('/', async (req, res) => {
) VALUES ( ) VALUES (
$1, $2, '', $3, $4, $1, $2, '', $3, $4,
$5, EXTRACT(EPOCH FROM NOW())::INTEGER, $5, EXTRACT(EPOCH FROM NOW())::INTEGER,
NOW(), $6, NOW(), $6 $6, $7, $6, $7
)`, )`,
[articleId, customerFrom, subject || title, finalBody, contentType, operatorId] [articleId, customerFrom, subject || title, finalBody, contentType, localNow, operatorId]
); );
// If HTML content, create article_data_mime_attachment for OTRS CE HTML rendering (file-1) // If HTML content, create article_data_mime_attachment for OTRS CE HTML rendering (file-1)
@@ -678,9 +680,9 @@ router.post('/', async (req, res) => {
create_time, create_by, change_time, change_by create_time, create_by, change_time, change_by
) VALUES ( ) VALUES (
$1, 'file-1', $2, 'text/html; charset="utf-8"', '', $3, $1, 'file-1', $2, 'text/html; charset="utf-8"', '', $3,
NOW(), $4, NOW(), $4 $4, $5, $4, $5
)`, )`,
[articleId, String(contentSize), base64Body, operatorId] [articleId, String(contentSize), base64Body, localNow, operatorId]
); );
} }
@@ -692,13 +694,14 @@ router.post('/', async (req, res) => {
`INSERT INTO article_data_mime_attachment ( `INSERT INTO article_data_mime_attachment (
article_id, filename, content_size, content_type, disposition, content, article_id, filename, content_size, content_type, disposition, content,
create_time, create_by, change_time, change_by create_time, create_by, change_time, change_by
) VALUES ($1, $2, $3, $4, 'attachment', $5, NOW(), $6, NOW(), $6)`, ) VALUES ($1, $2, $3, $4, 'attachment', $5, $6, $7, $6, $7)`,
[ [
articleId, articleId,
att.filename, att.filename,
contentBuffer.length, contentBuffer.length,
att.content_type || 'application/octet-stream', att.content_type || 'application/octet-stream',
att.content, // OTRS CE expects base64 string directly att.content, // OTRS CE expects base64 string directly
localNow,
operatorId operatorId
] ]
); );