lizerk ed636081dc refactor: complete notifications v2 system with frontend translation
- Remove hard-coded Russian translations from backend API
- Backend now returns raw verb values (language-agnostic)
- Implement frontend translation functions for notification titles and categories
- Add category badge system with filters on notifications page
- Create translation utilities in frontend (verbTranslations.ts)
- Add notification settings page structure
- Update API endpoints to return simplified notification data
- Refactor notification signals across all apps
- Remove deprecated code and tests
- Add comprehensive documentation for v2 migration

Backend changes:
- notifications/api/views.py: Remove translation logic, simplify responses
- All notification_signals.py: Update to use consistent patterns
- Remove deprecated Telegram bot command
- Update Celery tasks for new notification structure

Frontend changes:
- app/notifications/page.tsx: Add translation functions and category badges
- hooks/useNotificationWebSocket.ts: New WebSocket hook for real-time updates
- lib/verbTranslations.ts: Centralized translation mappings
- components/NotificationCenter.tsx: Update to use new API format

This makes the notifications module fully reusable and project-independent.
2026-03-09 21:35:36 +03:00

42 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Celery задачи для отправки Web Push уведомлений
"""
from .base import BaseNotificationTask
from notifications import config
class PushNotificationTask(BaseNotificationTask):
"""
Celery задача для асинхронной отправки Web Push уведомлений.
Особенности:
- Rate limiting: из config (default: 50 push/минуту)
- Retry: из config (default: 2 попытки с интервалом 1 минута)
- Автоматическое удаление неактивных устройств
"""
task_name = "notifications.send_push_notification"
max_retries = config.push_max_retries()
retry_delay = config.push_retry_delay()
rate_limit = config.push_rate_limit()
def send_notification(self, notification, **kwargs) -> bool:
"""
Отправляет Web Push через PushNotificationSender.
Args:
notification: Объект Notification
**kwargs: Дополнительные параметры
Returns:
True если успешно (хотя бы одно устройство), False иначе
"""
from notifications.senders.push import PushNotificationSender
sender = PushNotificationSender()
return sender.send(notification, **kwargs)
# Регистрируем задачу в Celery
send_push_notification = PushNotificationTask.register_task()