diff --git a/api/notifications.php b/api/notifications.php index c3d6449..e5c0586 100644 --- a/api/notifications.php +++ b/api/notifications.php @@ -225,10 +225,21 @@ foreach ($all as $row) { 'comment' => "{$row['actor_name']} commented on ticket #{$ticketId}", 'mention' => "{$row['actor_name']} mentioned you on ticket #{$ticketId}", 'update' => (function () use ($row, $details, $ticketId) { - // logTicketUpdate stores delta as {"status": {"from": "Open", "to": "In Progress"}} - $from = $details['status']['from'] ?? ($details['old_value'] ?? '?'); - $to = $details['status']['to'] ?? ($details['new_value'] ?? '?'); - return "{$row['actor_name']} changed status on #{$ticketId}: {$from} → {$to}"; + // Visibility changes log a flat {field, from, to} shape (api/update_ticket.php). + if (isset($details['field'], $details['from'], $details['to'])) { + return "{$row['actor_name']} changed {$details['field']} on #{$ticketId}: {$details['from']} → {$details['to']}"; + } + + // Single/bulk field updates log a per-field delta, e.g. + // {"status": {"from": "Open", "to": "In Progress"}}. Only one field + // changed at a time is reported, in priority order below. + foreach (['status', 'priority', 'title', 'category', 'type', 'description'] as $field) { + if (isset($details[$field]['from'], $details[$field]['to'])) { + return "{$row['actor_name']} changed {$field} on #{$ticketId}: {$details[$field]['from']} → {$details[$field]['to']}"; + } + } + + return "{$row['actor_name']} updated ticket #{$ticketId}"; })(), default => "{$row['actor_name']} updated ticket #{$ticketId}", };