Korjaa Zammad-vastauksen sähköpostilähetys
Lisätty subtype: 'reply' Zammad-artikkelin luontiin — ilman tätä Zammad luo artikkelin mutta ei lähetä sähköpostia vastaanottajalle. Myös plain-text muunnetaan HTML:ksi ja subject saa Re: -etuliitteen. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
10
api.php
10
api.php
@@ -305,16 +305,22 @@ 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'): array {
|
||||||
|
// Muunna plain-text HTML:ksi jos body ei sisällä HTML-tageja
|
||||||
|
$htmlBody = $body;
|
||||||
|
if (strip_tags($body) === $body) {
|
||||||
|
$htmlBody = nl2br(htmlspecialchars($body, ENT_QUOTES, 'UTF-8'));
|
||||||
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'ticket_id' => $ticketId,
|
'ticket_id' => $ticketId,
|
||||||
'body' => $body,
|
'body' => $htmlBody,
|
||||||
'content_type' => 'text/html',
|
'content_type' => 'text/html',
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
|
'subtype' => 'reply',
|
||||||
'internal' => false,
|
'internal' => false,
|
||||||
'sender' => 'Agent',
|
'sender' => 'Agent',
|
||||||
];
|
];
|
||||||
if ($to) $data['to'] = $to;
|
if ($to) $data['to'] = $to;
|
||||||
if ($subject) $data['subject'] = $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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user