Notification titles: handle non-status ticket edits (#84)
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MGDKHiU5RJdo3dqQUDow3X
This commit is contained in:
+15
-4
@@ -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}",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user