fix: Fix errors and small improvements

This commit is contained in:
2025-12-01 17:24:14 +03:00
parent 49b0201b5f
commit 3b2e2cb656
3 changed files with 4 additions and 0 deletions

View File

@@ -79,6 +79,8 @@ class LogsHandler
// Форматируем дату для отображения (убираем микросекунды и временную зону для читаемости) // Форматируем дату для отображения (убираем микросекунды и временную зону для читаемости)
$formattedDatetime = $this->formatDateTime($datetime); $formattedDatetime = $this->formatDateTime($datetime);
$message = rtrim($message, ' [] []');
$parsed[] = [ $parsed[] = [
'datetime' => $formattedDatetime, 'datetime' => $formattedDatetime,
'datetime_raw' => $datetime, 'datetime_raw' => $datetime,

View File

@@ -64,6 +64,7 @@ class SignatureValidator
$calculatedHash = bin2hex(hash_hmac($algorithm, $checkString, $secretKey, true)); $calculatedHash = bin2hex(hash_hmac($algorithm, $checkString, $secretKey, true));
if (! hash_equals($calculatedHash, $data['hash'])) { if (! hash_equals($calculatedHash, $data['hash'])) {
$this->logger->error('Request with invalid Telegram Signature. Check Telegram Bot Token is correct.');
throw new TelegramInvalidSignatureException('Invalid Telegram signature!'); throw new TelegramInvalidSignatureException('Invalid Telegram signature!');
} }
} }

View File

@@ -6,6 +6,7 @@ use Openguru\OpenCartFramework\Contracts\ExceptionHandlerInterface;
use Openguru\OpenCartFramework\Http\JsonResponse; use Openguru\OpenCartFramework\Http\JsonResponse;
use Openguru\OpenCartFramework\Http\Response; use Openguru\OpenCartFramework\Http\Response;
use Openguru\OpenCartFramework\Telegram\Exceptions\TelegramInvalidSignatureException; use Openguru\OpenCartFramework\Telegram\Exceptions\TelegramInvalidSignatureException;
use Psr\Log\LoggerInterface;
use Throwable; use Throwable;
class CustomExceptionHandler implements ExceptionHandlerInterface class CustomExceptionHandler implements ExceptionHandlerInterface