config->isPushEnabled()) { return false; } $preview = $this->truncate($messagePreview); if ($preview === '') { $preview = 'Новый ответ от поддержки'; } $subject = trim((string)$ticketSubject); $link = $this->urlGenerator->linkToRouteAbsolute('f7support.page.index') . '?ticket=' . rawurlencode($ticketNumber); $notification = $this->notificationManager->createNotification(); $notification ->setApp('f7support') ->setUser($userId) ->setDateTime(new \DateTime()) ->setObject('ticket', $ticketNumber) ->setSubject('support_reply', [ 'ticketNumber' => $ticketNumber, 'ticketSubject' => $subject, 'preview' => $preview, ]) ->setMessage('support_reply', [ 'preview' => $preview, ]) ->setLink($link); try { $this->notificationManager->notify($notification); $this->logger->debug('f7support: push notification queued', [ 'app' => 'f7support', 'user' => $userId, 'ticket' => $ticketNumber, ]); return true; } catch (\Throwable $e) { $this->logger->warning('f7support: failed to queue push notification', [ 'app' => 'f7support', 'user' => $userId, 'ticket' => $ticketNumber, 'exception' => $e, ]); return false; } } private function truncate(string $text): string { $text = trim(preg_replace('/\s+/u', ' ', $text) ?? $text); if ($text === '' || mb_strlen($text) <= self::PREVIEW_MAX) { return $text; } return mb_substr($text, 0, self::PREVIEW_MAX - 1) . '…'; } }