Liitteiden näyttö Zammad-viesteissä + download proxy

- dbLoadTickets: attachments & zammad_article_id mukaan viestidataan
- ticket_detail on-demand: liitteiden metadata talteen (sama kuin sync)
- Uusi zammad_attachment proxy-endpoint liitteiden lataukseen
- JS: liitteet näkyvät tikettiviesteissä (ikoni, nimi, koko, latauslinkki)
- CSS: .msg-attachments ja .msg-attachment-link tyylit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 03:14:15 +02:00
parent 376912b9ff
commit dc0ed5c75c
5 changed files with 165 additions and 9 deletions

12
db.php
View File

@@ -679,6 +679,7 @@ function initDatabase(): void {
"ALTER TABLE availability_queries ADD COLUMN org VARCHAR(255) DEFAULT '' AFTER hostname",
"ALTER TABLE tickets ADD COLUMN to_email VARCHAR(255) DEFAULT '' AFTER from_name",
"ALTER TABLE tickets ADD COLUMN bcc TEXT DEFAULT '' AFTER cc",
"ALTER TABLE ticket_messages ADD COLUMN attachments TEXT DEFAULT '' AFTER zammad_article_id",
];
foreach ($alters as $sql) {
try { $db->query($sql); } catch (\Throwable $e) { /* sarake on jo olemassa / jo ajettu */ }
@@ -1406,7 +1407,7 @@ function dbLoadTickets(string $companyId): array {
// Viestit
$msgs = _dbFetchAll("SELECT * FROM ticket_messages WHERE ticket_id = ? ORDER BY timestamp", [$t['id']]);
$t['messages'] = array_map(function($m) {
return [
$msg = [
'id' => $m['id'],
'type' => $m['type'],
'from' => $m['from_email'],
@@ -1415,6 +1416,15 @@ function dbLoadTickets(string $companyId): array {
'timestamp' => $m['timestamp'],
'message_id' => $m['message_id'] ?? '',
];
// Liitteiden metadata (JSON)
if (!empty($m['attachments'])) {
$msg['attachments'] = json_decode($m['attachments'], true) ?: [];
}
// Zammad article ID (tarvitaan liitteiden lataukseen)
if (!empty($m['zammad_article_id'])) {
$msg['zammad_article_id'] = (int)$m['zammad_article_id'];
}
return $msg;
}, $msgs);
// Tagit