From 7346f2977afb661c06392a35b81846ab0bbf2588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=9D=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Wed, 3 Dec 2025 12:54:05 +0300 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20notification-manager=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=20=D0=B0=D1=80=D1=85=D0=B8=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D1=83=D1=80=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Изменен WebSocket URL: /ws/notifications/ -> /ws/ - Обновлен обработчик типа 'notification' (вместо 'new_notification') - Добавлена обратная совместимость для старых типов сообщений - Теперь уведомления приходят через универсальный UserConsumer --- backend/realtime/models.py | 3 --- backend/realtime/tests.py | 3 --- backend/realtime/views.py | 3 --- .../static/js/notifications/notification-manager.js | 11 +++++++++-- 4 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 backend/realtime/models.py delete mode 100644 backend/realtime/tests.py delete mode 100644 backend/realtime/views.py diff --git a/backend/realtime/models.py b/backend/realtime/models.py deleted file mode 100644 index 71a83623..00000000 --- a/backend/realtime/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/backend/realtime/tests.py b/backend/realtime/tests.py deleted file mode 100644 index 7ce503c2..00000000 --- a/backend/realtime/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/backend/realtime/views.py b/backend/realtime/views.py deleted file mode 100644 index 91ea44a2..00000000 --- a/backend/realtime/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here. diff --git a/backend/static/js/notifications/notification-manager.js b/backend/static/js/notifications/notification-manager.js index b11bb043..68e389ce 100644 --- a/backend/static/js/notifications/notification-manager.js +++ b/backend/static/js/notifications/notification-manager.js @@ -95,7 +95,8 @@ class NotificationManager { connectWebSocket() { const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - const wsUrl = `${protocol}//${window.location.host}/ws/notifications/`; + // Используем универсальный WebSocket endpoint (realtime architecture) + const wsUrl = `${protocol}//${window.location.host}/ws/`; console.log('[Notifications] Connecting to:', wsUrl); @@ -145,7 +146,13 @@ class NotificationManager { this.updateBadge(data.count); break; - case 'new_notification': + case 'notification': // UserConsumer использует "notification" + this.showNewNotification(data.notification); + // Инвалидируем кеш при получении нового уведомления + invalidateNotifications(); + break; + + case 'new_notification': // Backwards compatibility this.showNewNotification(data.notification); this.updateBadge(data.notification.unread_count); // Инвалидируем кеш при получении нового уведомления