BREAKING CHANGES: - API полностью переписан под новую модель (verb вместо category/type) - NotificationService заменен на stub с NotImplementedError - Удалена обратная совместимость API endpoints (обновлены): - GET /api/v1/notifications/ - новый формат ответа - GET /api/v1/notifications/verb-types/ - вместо categories - GET/PUT /api/v1/notifications/preferences/ - вместо settings - POST /api/v1/notifications/<id>/unread/ - новый endpoint - DELETE /api/v1/notifications/delete-all-read/ - новый endpoint Удалены endpoints: - /api/v1/notifications/categories/ (нет категорий в v2) - /api/v1/notifications/settings/* (заменено на preferences) - /api/v1/notifications/telegram/* (Telegram отключен) - /api/v1/notifications/push/vapid-key/ (не нужен) - /api/v1/notifications/push/subscriptions/ (не нужен) services.py: - Заменен на stub с NotImplementedError - Все методы выбрасывают исключения с подсказками миграции - Документация как мигрировать со старого API Новая структура ответа API: - verb вместо category/type - actor (GenericForeignKey) вместо sender - description вместо message/title - timesince() вместо created_at - unread вместо is_read Старые файлы: - Удалены все *.old файлы
91 lines
2.9 KiB
Python
91 lines
2.9 KiB
Python
"""
|
||
DEPRECATED: Этот модуль удален в v2.0
|
||
|
||
Вместо NotificationService используйте:
|
||
|
||
1. Создание уведомлений:
|
||
|
||
СТАРОЕ:
|
||
NotificationService.create_notification(
|
||
recipient=user,
|
||
notification_type_code='message',
|
||
title='Заголовок',
|
||
message='Текст',
|
||
action_url='/link/'
|
||
)
|
||
|
||
НОВОЕ:
|
||
from notifications.signals import notify
|
||
notify.send(
|
||
sender=actor,
|
||
recipient=user,
|
||
verb='messaged',
|
||
description='Текст',
|
||
action_url='/link/'
|
||
)
|
||
|
||
2. Отметка как прочитанное:
|
||
|
||
СТАРОЕ:
|
||
NotificationService.mark_as_read(notification_id, user)
|
||
|
||
НОВОЕ:
|
||
notification = Notification.objects.get(id=notification_id)
|
||
notification.mark_as_read()
|
||
|
||
3. Настройки:
|
||
|
||
СТАРОЕ:
|
||
settings = NotificationService.get_user_settings(user)
|
||
|
||
НОВОЕ:
|
||
prefs = UserChannelPreferences.objects.get(user=user)
|
||
# или через related name:
|
||
prefs = user.channel_preferences
|
||
|
||
Документация: backend/notifications/README.md
|
||
"""
|
||
|
||
# Для обратной совместимости можно оставить минимальный stub
|
||
# который будет выбрасывать ошибки с подсказками как мигрировать
|
||
|
||
class NotificationService:
|
||
"""DEPRECATED: Удален в v2.0. См. docstring модуля."""
|
||
|
||
@staticmethod
|
||
def create_notification(*args, **kwargs):
|
||
raise NotImplementedError(
|
||
"NotificationService.create_notification() удален. "
|
||
"Используйте: notify.send(sender=actor, recipient=user, verb='...', description='...')"
|
||
)
|
||
|
||
@staticmethod
|
||
def create_notification_async(*args, **kwargs):
|
||
raise NotImplementedError(
|
||
"NotificationService.create_notification_async() удален. "
|
||
"Все уведомления теперь асинхронны через Celery. "
|
||
"Используйте: notify.send(...)"
|
||
)
|
||
|
||
@staticmethod
|
||
def mark_as_read(*args, **kwargs):
|
||
raise NotImplementedError(
|
||
"NotificationService.mark_as_read() удален. "
|
||
"Используйте: notification.mark_as_read()"
|
||
)
|
||
|
||
@staticmethod
|
||
def mark_all_as_read(*args, **kwargs):
|
||
raise NotImplementedError(
|
||
"NotificationService.mark_all_as_read() удален. "
|
||
"Используйте: Notification.objects.filter(...).mark_all_as_read()"
|
||
)
|
||
|
||
@staticmethod
|
||
def get_user_settings(*args, **kwargs):
|
||
raise NotImplementedError(
|
||
"NotificationService.get_user_settings() удален. "
|
||
"Используйте: user.channel_preferences или UserChannelPreferences.objects.get(user=user)"
|
||
)
|
||
|