ticket = $ticket; $this->customer = $customer; } /** * Execute the job. */ public function handle(): void { // Loại bỏ base64 images và strip HTML tags $cleanDescription = $this->ticket->description; // Loại bỏ base64 images $cleanDescription = preg_replace('/]+src="data:image\/[^;]+;base64,[^"]+"[^>]*>/i', '[Hình ảnh]', $cleanDescription); // Strip HTML tags còn lại $cleanDescription = strip_tags($cleanDescription); // Gửi thông báo Telegram khi tạo ticket mới $message = "🆕 Ticket mới được tạo!\n"; $message .= "👤 Khách: {$this->customer->fullname} ({$this->customer->email})\n"; $message .= "🎫 Số ticket: #{$this->ticket->ticket_num}\n"; $message .= "📄 Tiêu đề: {$this->ticket->subject}\n"; $message .= "🏢 Phòng ban: {$this->ticket->roomLabel()}\n"; $message .= "📝 Nội dung: " . $cleanDescription; // Kiểm tra độ dài message (Telegram giới hạn 4096 ký tự) if (strlen($message) > 4000) { $message = substr($message, 0, 3990) . "...[cắt ngắn]"; } app(\App\Http\Services\Telegram::class)->SendMessage($message); // Nếu có file đính kèm, gửi hình ảnh lên Telegram $data = json_decode($this->ticket->data, true); if (!empty($data['file'])) { $caption = "[Ticket #{$this->ticket->ticket_num}] " . ($this->ticket->subject ?? ''); app(\App\Http\Services\Telegram::class)->SendPhoto($data['file'], $caption); } } }