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 */
|
||||
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
|
||||
$htmlBody = $body;
|
||||
if (strip_tags($body) === $body) {
|
||||
@@ -320,6 +320,7 @@ class ZammadClient {
|
||||
'sender' => 'Agent',
|
||||
];
|
||||
if ($to) $data['to'] = $to;
|
||||
if ($cc) $data['cc'] = $cc;
|
||||
if ($subject) $data['subject'] = 'Re: ' . preg_replace('/^Re:\s*/i', '', $subject);
|
||||
return $this->request('POST', 'ticket_articles', $data);
|
||||
}
|
||||
@@ -5319,11 +5320,15 @@ switch ($action) {
|
||||
|
||||
try {
|
||||
$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(
|
||||
(int)$ticket['zammad_ticket_id'],
|
||||
$body,
|
||||
$ticket['from_email'] ?? '',
|
||||
$ticket['subject'] ?? ''
|
||||
$to,
|
||||
$ticket['subject'] ?? '',
|
||||
'email',
|
||||
$cc
|
||||
);
|
||||
|
||||
// Tallenna myös paikalliseen tietokantaan
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Noxus HUB</title>
|
||||
<link rel="stylesheet" href="style.css?v=20260313h">
|
||||
<link rel="stylesheet" href="style.css?v=20260313i">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Login -->
|
||||
@@ -2233,6 +2233,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="script.js?v=20260313h"></script>
|
||||
<script src="script.js?v=20260313i"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -2027,8 +2027,13 @@ document.getElementById('btn-send-reply').addEventListener('click', async () =>
|
||||
}
|
||||
if (zSig) zBody += '\n\n-- \n' + zSig;
|
||||
}
|
||||
// Lähetä Zammad API:n kautta
|
||||
await apiCall('zammad_reply' + ticketCompanyParam(), 'POST', { ticket_id: currentTicketId, body: zBody });
|
||||
// Lähetä Zammad API:n kautta — välitä myös to/cc-kentät
|
||||
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 {
|
||||
const action = ticketReplyType === 'note' ? 'ticket_note' : 'ticket_reply';
|
||||
const payload = { id: currentTicketId, body };
|
||||
|
||||
Reference in New Issue
Block a user