Välitä To/CC-kentät Zammad-vastauksissa
JS ei lähettänyt käyttäjän muokkaamaa To/CC-kenttää Zammad-vastauksen mukana — backend käytti aina alkuperäistä lähettäjää tietokannasta. Nyt käyttäjän syöttämä To/CC välitetään API:lle ja Zammadille. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
11
api.php
11
api.php
@@ -304,7 +304,7 @@ class ZammadClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Lähetä vastaus tikettiin */
|
/** Lähetä vastaus tikettiin */
|
||||||
public function createArticle(int $ticketId, string $body, string $to = '', string $subject = '', string $type = 'email'): array {
|
public function createArticle(int $ticketId, string $body, string $to = '', string $subject = '', string $type = 'email', string $cc = ''): array {
|
||||||
// Muunna plain-text HTML:ksi jos body ei sisällä HTML-tageja
|
// Muunna plain-text HTML:ksi jos body ei sisällä HTML-tageja
|
||||||
$htmlBody = $body;
|
$htmlBody = $body;
|
||||||
if (strip_tags($body) === $body) {
|
if (strip_tags($body) === $body) {
|
||||||
@@ -320,6 +320,7 @@ class ZammadClient {
|
|||||||
'sender' => 'Agent',
|
'sender' => 'Agent',
|
||||||
];
|
];
|
||||||
if ($to) $data['to'] = $to;
|
if ($to) $data['to'] = $to;
|
||||||
|
if ($cc) $data['cc'] = $cc;
|
||||||
if ($subject) $data['subject'] = 'Re: ' . preg_replace('/^Re:\s*/i', '', $subject);
|
if ($subject) $data['subject'] = 'Re: ' . preg_replace('/^Re:\s*/i', '', $subject);
|
||||||
return $this->request('POST', 'ticket_articles', $data);
|
return $this->request('POST', 'ticket_articles', $data);
|
||||||
}
|
}
|
||||||
@@ -5319,11 +5320,15 @@ switch ($action) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$z = new ZammadClient($integ['config']['url'], $integ['config']['token']);
|
$z = new ZammadClient($integ['config']['url'], $integ['config']['token']);
|
||||||
|
$to = !empty($input['to']) ? trim($input['to']) : ($ticket['from_email'] ?? '');
|
||||||
|
$cc = !empty($input['cc']) ? trim($input['cc']) : '';
|
||||||
$result = $z->createArticle(
|
$result = $z->createArticle(
|
||||||
(int)$ticket['zammad_ticket_id'],
|
(int)$ticket['zammad_ticket_id'],
|
||||||
$body,
|
$body,
|
||||||
$ticket['from_email'] ?? '',
|
$to,
|
||||||
$ticket['subject'] ?? ''
|
$ticket['subject'] ?? '',
|
||||||
|
'email',
|
||||||
|
$cc
|
||||||
);
|
);
|
||||||
|
|
||||||
// Tallenna myös paikalliseen tietokantaan
|
// Tallenna myös paikalliseen tietokantaan
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Noxus HUB</title>
|
<title>Noxus HUB</title>
|
||||||
<link rel="stylesheet" href="style.css?v=20260313h">
|
<link rel="stylesheet" href="style.css?v=20260313i">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Login -->
|
<!-- Login -->
|
||||||
@@ -2233,6 +2233,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="script.js?v=20260313h"></script>
|
<script src="script.js?v=20260313i"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -2027,8 +2027,13 @@ document.getElementById('btn-send-reply').addEventListener('click', async () =>
|
|||||||
}
|
}
|
||||||
if (zSig) zBody += '\n\n-- \n' + zSig;
|
if (zSig) zBody += '\n\n-- \n' + zSig;
|
||||||
}
|
}
|
||||||
// Lähetä Zammad API:n kautta
|
// Lähetä Zammad API:n kautta — välitä myös to/cc-kentät
|
||||||
await apiCall('zammad_reply' + ticketCompanyParam(), 'POST', { ticket_id: currentTicketId, body: zBody });
|
const zPayload = { ticket_id: currentTicketId, body: zBody };
|
||||||
|
const zToFld = document.getElementById('reply-to');
|
||||||
|
const zCcFld = document.getElementById('reply-cc');
|
||||||
|
if (zToFld && zToFld.value.trim()) zPayload.to = zToFld.value.trim();
|
||||||
|
if (zCcFld && zCcFld.value.trim()) zPayload.cc = zCcFld.value.trim();
|
||||||
|
await apiCall('zammad_reply' + ticketCompanyParam(), 'POST', zPayload);
|
||||||
} else {
|
} else {
|
||||||
const action = ticketReplyType === 'note' ? 'ticket_note' : 'ticket_reply';
|
const action = ticketReplyType === 'note' ? 'ticket_note' : 'ticket_reply';
|
||||||
const payload = { id: currentTicketId, body };
|
const payload = { id: currentTicketId, body };
|
||||||
|
|||||||
Reference in New Issue
Block a user