forked from fa/breadcrumb-the-shire
feat(helpdesk): add ticket file download and inline image preview
New SOAP method getTicketFile() on BcSoapGateway calls BC's GetTicketFile to retrieve file attachments as Base64, decodes in memory and returns binary data without writing to disk. New proxy endpoint helpdesk/ticket-file-data streams files directly to the browser with correct MIME type. Images served inline, other files as download attachment. TicketCommunicationService now attaches file_entry_no and file_name to file-type events. Frontend renders download links with bi-download icon and inline image previews for jpg/png/gif attachments. Works in both ticket detail and debitor detail communication feeds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -287,6 +287,8 @@ class TicketCommunicationService
|
||||
'type_variant' => $typeVariant,
|
||||
'state_subtype' => $stateSubtype,
|
||||
'message' => $message,
|
||||
'file_entry_no' => $typeVariant === 'file' ? $entryNo : '',
|
||||
'file_name' => $typeVariant === 'file' ? $this->extractFilenameFromMessage($message, $recordId) : '',
|
||||
'source' => $soapMessage !== '' ? 'soap' : 'odata',
|
||||
];
|
||||
|
||||
@@ -1053,6 +1055,29 @@ class TicketCommunicationService
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a filename from the message or record ID of a file-type log entry.
|
||||
*/
|
||||
private function extractFilenameFromMessage(string $message, string $recordId): string
|
||||
{
|
||||
// Message itself may contain the filename
|
||||
$trimmed = trim($message);
|
||||
if ($trimmed !== '' && str_contains($trimmed, '.') && !str_contains($trimmed, ' ')) {
|
||||
return $trimmed;
|
||||
}
|
||||
|
||||
// Record_ID sometimes contains the filename
|
||||
$recordTrimmed = trim($recordId);
|
||||
if ($recordTrimmed !== '' && str_contains($recordTrimmed, '.')) {
|
||||
// Extract last segment after colon or space that looks like a filename
|
||||
if (preg_match('/([^\s:]+\.\w{2,5})$/i', $recordTrimmed, $m)) {
|
||||
return $m[1];
|
||||
}
|
||||
}
|
||||
|
||||
return $trimmed !== '' ? $trimmed : '';
|
||||
}
|
||||
|
||||
private function normalizeActorRole(string $createdByType, string $actor): string
|
||||
{
|
||||
$type = mb_strtolower(trim($createdByType));
|
||||
|
||||
Reference in New Issue
Block a user