diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index 4354a8dc6..93791cacf 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -699,7 +699,16 @@ class WebSocketDialogMsg extends AbstractModel $text = preg_replace("/\[:#:(.*?):(.*?):\]/i", "#$2", $text); $text = preg_replace("/\[:~:(.*?):(.*?):\]/i", "~$2", $text); $text = preg_replace_callback("/\[:LINK:(.*?):(.*?):\]/i", function (array $match) { - return "" . base64_decode($match[2]) . ""; + $link = base64_decode($match[1]); + $title = base64_decode($match[2]); + preg_match("/\/single\/file\/(.*?)$/i", $title, $match); + if ($match && strlen($match[1]) >= 32) { + $file = File::select(['files.id', 'files.name', 'files.ext'])->join('file_links as L', 'files.id', '=', 'L.file_id')->where('L.code', $match[1])->first(); + if ($file && $file->name) { + $title = $file->ext ? "{$file->name}.{$file->ext}" : $file->name; + } + } + return "{$title}"; }, $text); return preg_replace("/^(

<\/p>)+|(

<\/p>)+$/i", "", $text); }