- Add ContextVarsMiddleware for automatic user_id/chat_id/username binding
via structlog contextvars (aiogram) and http_method/http_path (FastAPI)
- Use bound_contextvars() context manager instead of clear_contextvars()
to safely restore previous state instead of wiping all context
- Register ContextVarsMiddleware as outermost middleware (before GlobalError)
so all error logs include user context
- Replace structlog.get_logger() with structlog.get_logger(__name__) across
270 calls in 265 files for meaningful logger names
- Switch wrapper_class from BoundLogger to make_filtering_bound_logger()
for pre-processor level filtering (performance optimization)
- Migrate 1411 %-style positional arg logger calls to structlog kwargs
style across 161 files via AST script
- Migrate log_rotation_service.py from stdlib logging to structlog
- Add payment module prefixes to TelegramNotifierProcessor.IGNORED_LOGGER_PREFIXES
and ExcludePaymentFilter.PAYMENT_MODULES to prevent payment data leaking
to Telegram notifications and general log files
- Fix LoggingMiddleware: add from_user null-safety for channel posts,
switch time.time() to time.monotonic() for duration measurement
- Remove duplicate logger assignments in purchase.py, config.py,
inline.py, and admin/payments.py
- Add pyproject.toml with uv and ruff configuration
- Pin Python version to 3.13 via .python-version
- Add Makefile commands: lint, format, fix
- Apply ruff formatting to entire codebase
- Remove unused imports (base64 in yookassa/simple_subscription)
- Update .gitignore for new config files
Реализована отказоустойчивая система отправки чеков в налоговую:
- Добавлен NalogoQueueService для фоновой обработки очереди чеков
- При недоступности nalog.ru (503) чеки сохраняются в Redis
- Автоматическая повторная отправка с настраиваемым интервалом
- Защита от DDoS: задержка между чеками (NALOGO_QUEUE_RECEIPT_DELAY)
- Уведомления админам в топик при проблемах и успешной разгрузке
Изменения в файлах:
- app/services/nalogo_queue_service.py: новый фоновый сервис
- app/services/nalogo_service.py: методы очереди, определение 503
- app/utils/cache.py: lpush/rpop/llen/lrange для Redis List
- app/handlers/admin/monitoring.py: статистика чеков в админке
- app/config.py: NALOGO_QUEUE_* и ADMIN_NOTIFICATIONS_NALOG_TOPIC_ID
- main.py: интеграция запуска/остановки сервиса
Новые ENV переменные:
- ADMIN_NOTIFICATIONS_NALOG_TOPIC_ID
- NALOGO_QUEUE_CHECK_INTERVAL (300с)
- NALOGO_QUEUE_RECEIPT_DELAY (3с)
- NALOGO_QUEUE_MAX_ATTEMPTS (10)