From 6183bcd4219714a3436b5fe5ea4f74e95ac95ed8 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Tue, 8 Sep 2026 10:41:29 -0400 Subject: [PATCH] Notification titles: handle non-status ticket edits (#84) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'update' notification formatter unconditionally read details['status']['from']/['to'], so any title/priority/description/ category/type/visibility-only edit fell through to '?' on both sides and produced a broken "changed status on #123: ? → ?" title regardless of what actually changed. Now it branches on the delta shape actually present: the flat {field, from, to} shape used for visibility changes, then each per-field {from, to} delta in priority order, falling back to a generic "updated ticket" message only if none match. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01MGDKHiU5RJdo3dqQUDow3X --- api/notifications.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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}", };