diff --git a/api.php b/api.php index a34ca73..f716b90 100644 --- a/api.php +++ b/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 diff --git a/index.html b/index.html index a69d081..19e157a 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@