forked from fa/breadcrumb-the-shire
fix(helpdesk): resolve all support actor codes instead of requiring exactly one per ticket
The previous logic only resolved support user codes to full names when exactly one unique support code existed per ticket. Tickets with multiple support codes (e.g. after reassignment) left all codes unresolved, showing abbreviations like 'NKS' or 'FA' instead of full names. Now: every support-role actor code in a ticket is mapped to that ticket's Support_User_Name. For the debitor feed, codes are mapped on first encounter to avoid conflicts from reassigned tickets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -924,7 +924,7 @@ class TicketCommunicationService
|
||||
return [];
|
||||
}
|
||||
|
||||
$supportCodes = [];
|
||||
$result = [];
|
||||
foreach ([...$odataEntries, ...$soapEntries] as $entry) {
|
||||
$actorRole = trim((string) ($entry['actor_role'] ?? ''));
|
||||
if ($actorRole !== 'support') {
|
||||
@@ -932,17 +932,11 @@ class TicketCommunicationService
|
||||
}
|
||||
$actor = strtoupper(trim((string) ($entry['actor'] ?? '')));
|
||||
if ($actor !== '' && !$this->isContactActorId($actor) && mb_strlen($actor) <= 10) {
|
||||
$supportCodes[$actor] = true;
|
||||
$result[$actor] = $supportUserName;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($supportCodes) !== 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$code = array_keys($supportCodes)[0];
|
||||
|
||||
return [$code => $supportUserName];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -962,8 +956,11 @@ class TicketCommunicationService
|
||||
return [];
|
||||
}
|
||||
|
||||
// Group support actor codes per ticket
|
||||
$codesByTicket = [];
|
||||
// Map support actor codes to names using ticket assignment data.
|
||||
// For each entry with a support role, look up the ticket's Support_User_Name
|
||||
// and map the actor code to that name. This handles tickets with multiple
|
||||
// support codes (e.g. after reassignment) robustly.
|
||||
$result = [];
|
||||
foreach ($entries as $entry) {
|
||||
$actorRole = trim((string) ($entry['actor_role'] ?? ''));
|
||||
if ($actorRole !== 'support') {
|
||||
@@ -977,20 +974,10 @@ class TicketCommunicationService
|
||||
if ($ticketNo === '') {
|
||||
continue;
|
||||
}
|
||||
$codesByTicket[$ticketNo][$actor] = true;
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($codesByTicket as $ticketNo => $codes) {
|
||||
if (count($codes) !== 1) {
|
||||
continue;
|
||||
}
|
||||
$supportUserName = $supportUserNamesByTicket[$ticketNo] ?? '';
|
||||
if ($supportUserName === '') {
|
||||
continue;
|
||||
if ($supportUserName !== '' && !isset($result[$actor])) {
|
||||
$result[$actor] = $supportUserName;
|
||||
}
|
||||
$code = array_keys($codes)[0];
|
||||
$result[$code] = $supportUserName;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
Reference in New Issue
Block a user