diff --git a/backend/notifications/README.md b/backend/notifications/README.md index 5670a0ea..a4c0a394 100644 --- a/backend/notifications/README.md +++ b/backend/notifications/README.md @@ -49,6 +49,24 @@ notification.mark_as_read() ## 📚 Документация +## 🚧 TODO + +### Критичные задачи: +- [ ] Написать unit и integration тесты (coverage >80%) +- [ ] Создать email шаблоны (notification.html/txt, digest.html/txt) +- [ ] Убрать хардкод 'EUSRR' из email sender + +### Важные улучшения: +- [ ] Переместить API endpoints в notifications/api/ +- [ ] Создать notifications/settings.py для централизованной конфигурации +- [ ] Добавить больше примеров использования в README + +### Желательно: +- [ ] Подготовить setup.py для публикации в PyPI +- [ ] Sphinx документация +- [ ] CI/CD pipeline (GitHub Actions) +- [ ] Pre-commit hooks для линтеров + Полная документация: [`backend/docs/guides/NOTIFICATIONS_V2_USAGE.md`](../docs/guides/NOTIFICATIONS_V2_USAGE.md) ## 🏗️ Архитектура diff --git a/backend/notifications/channels.py b/backend/notifications/channels.py index 35a5bdc6..18b4f0c0 100644 --- a/backend/notifications/channels.py +++ b/backend/notifications/channels.py @@ -5,6 +5,12 @@ - WebSocket (realtime) - мгновенно - Email - с retry и rate limiting - Web Push - с автоматическим удалением неактивных устройств + +TODO: Добавить integration тесты: + - Проверка вызова Celery tasks при создании Notification + - Режим DND (только WebSocket silent) + - Отключенные каналы (email_enabled=False) + - Отключенные verb'ы (is_verb_enabled) """ from django.db.models.signals import post_save diff --git a/backend/notifications/models.py b/backend/notifications/models.py index cbf3726c..b4f1e532 100644 --- a/backend/notifications/models.py +++ b/backend/notifications/models.py @@ -7,6 +7,13 @@ - GenericForeignKey для универсальности - Простой API через сигналы - Multi-channel поддержка (Web, Email, Push) + +TODO: Добавить тесты для моделей: + - NotificationQuerySet методы (unread, read, mark_all_as_*) + - Notification.mark_as_read/unread() + - Notification.timesince() + - UserChannelPreferences.is_verb_enabled() + - UserChannelPreferences.is_in_dnd_period() """ from django.db import models diff --git a/backend/notifications/senders/email.py b/backend/notifications/senders/email.py index 9ae676d3..ddab42c2 100644 --- a/backend/notifications/senders/email.py +++ b/backend/notifications/senders/email.py @@ -1,5 +1,11 @@ """ Email отправитель для системы уведомлений + +TODO: Создать email шаблоны: + - templates/notifications/email/notification.html + - templates/notifications/email/notification.txt + - templates/notifications/email/digest.html + - templates/notifications/email/digest.txt """ from typing import Optional @@ -80,6 +86,7 @@ class EmailNotificationSender(BaseNotificationSender): 'description': notification.description, 'action_url': self._get_full_url(notification.action_url), 'action_text': 'Посмотреть', + # TODO: Убрать хардкод 'EUSRR', использовать 'My Site' как fallback 'site_name': getattr(settings, 'SITE_NAME', 'EUSRR'), 'site_url': self._get_site_url(), 'verb_icon': self.VERB_ICONS.get(notification.verb, '🔔'), @@ -151,6 +158,7 @@ class EmailNotificationSender(BaseNotificationSender): 'digest_name': digest_name, 'total_count': len(notifications), 'verb_icons': self.VERB_ICONS, + # TODO: Убрать хардкод 'EUSRR', использовать 'My Site' как fallback 'site_name': getattr(settings, 'SITE_NAME', 'EUSRR'), 'site_url': self._get_site_url(), } diff --git a/backend/notifications/signals.py b/backend/notifications/signals.py index 3fe18223..0ce2b904 100644 --- a/backend/notifications/signals.py +++ b/backend/notifications/signals.py @@ -14,6 +14,12 @@ description='liked your comment on "Post Title"', action_url='/posts/123/', ) + +TODO: Добавить тесты для: + - Создания уведомления через notify.send() + - Множественных получателей (recipient=[user1, user2]) + - Валидации параметров (recipient required, verb required) + - GenericForeignKey полей (actor, action_object, target) """ from django.dispatch import Signal diff --git a/backend/notifications/tasks/email.py b/backend/notifications/tasks/email.py index 2581f917..3aca18ca 100644 --- a/backend/notifications/tasks/email.py +++ b/backend/notifications/tasks/email.py @@ -1,5 +1,10 @@ """ Celery задачи для отправки email уведомлений + +TODO: Вынести конфигурацию в settings: + - NOTIFICATIONS_EMAIL_RATE_LIMIT (сейчас '10/m') + - NOTIFICATIONS_EMAIL_MAX_RETRIES (сейчас 3) + - NOTIFICATIONS_EMAIL_RETRY_DELAY (сейчас 300) """ from .base import BaseNotificationTask diff --git a/backend/notifications/tasks/push.py b/backend/notifications/tasks/push.py index 36deaff0..28188bef 100644 --- a/backend/notifications/tasks/push.py +++ b/backend/notifications/tasks/push.py @@ -1,5 +1,10 @@ """ Celery задачи для отправки Web Push уведомлений + +TODO: Вынести конфигурацию в settings: + - NOTIFICATIONS_PUSH_RATE_LIMIT (сейчас '50/m') + - NOTIFICATIONS_PUSH_MAX_RETRIES (сейчас 2) + - NOTIFICATIONS_PUSH_RETRY_DELAY (сейчас 60) """ from .base import BaseNotificationTask