fix: corretta ora di creazione dei ticket che non considerava il fusorario.
This commit is contained in:
+14
-11
@@ -530,6 +530,8 @@ router.post('/', async (req, res) => {
|
||||
// Operator user for create_by (X-Agent-ID header or default to 1)
|
||||
const operatorId = parseInt(req.headers['x-agent-id'], 10) || 1;
|
||||
|
||||
const localNow = getLocalTimestamp();
|
||||
|
||||
const ticketResult = await client.query(
|
||||
`INSERT INTO ticket (
|
||||
tn, title, queue_id, ticket_lock_id, type_id,
|
||||
@@ -550,14 +552,14 @@ router.post('/', async (req, res) => {
|
||||
0, 0,
|
||||
0, 0,
|
||||
0,
|
||||
NOW(), $12, NOW(), $12
|
||||
$12, $13, $12, $13
|
||||
) RETURNING id, tn`,
|
||||
[
|
||||
tn, title, queue_id, lockId, type_id || null,
|
||||
user_id || 1, responsibleUserId,
|
||||
priority_id, state_id,
|
||||
customer_id || null, customer_user_id || null,
|
||||
operatorId
|
||||
localNow, operatorId
|
||||
]
|
||||
);
|
||||
|
||||
@@ -578,13 +580,13 @@ router.post('/', async (req, res) => {
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5,
|
||||
$6, $7, $8,
|
||||
NOW(), $9, NOW(), $9
|
||||
$9, $10, $9, $10
|
||||
)`,
|
||||
[
|
||||
`%%`,
|
||||
historyTypeId, ticketId, type_id || 1, queue_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,
|
||||
create_time, create_by, change_time, change_by
|
||||
) VALUES (
|
||||
$1, $2, $3, 0, 1, NOW(), $4, NOW(), $4
|
||||
$1, $2, $3, 0, 1, $4, $5, $4, $5
|
||||
) RETURNING id`,
|
||||
[ticketId, senderTypeId, channelId, operatorId]
|
||||
[ticketId, senderTypeId, channelId, localNow, operatorId]
|
||||
);
|
||||
|
||||
const articleId = articleResult.rows[0].id;
|
||||
@@ -660,9 +662,9 @@ router.post('/', async (req, res) => {
|
||||
) VALUES (
|
||||
$1, $2, '', $3, $4,
|
||||
$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)
|
||||
@@ -678,9 +680,9 @@ router.post('/', async (req, res) => {
|
||||
create_time, create_by, change_time, change_by
|
||||
) VALUES (
|
||||
$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 (
|
||||
article_id, filename, content_size, content_type, disposition, content,
|
||||
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,
|
||||
att.filename,
|
||||
contentBuffer.length,
|
||||
att.content_type || 'application/octet-stream',
|
||||
att.content, // OTRS CE expects base64 string directly
|
||||
localNow,
|
||||
operatorId
|
||||
]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user