From ec2a73fd94050459658ebcf63c7e992f60384bf4 Mon Sep 17 00:00:00 2001 From: lizerk Date: Thu, 16 Apr 2026 22:02:33 +0300 Subject: [PATCH] fix: route push notifications to target urls --- backend/notifications/senders/push.py | 1 + frontend/public/sw.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/backend/notifications/senders/push.py b/backend/notifications/senders/push.py index 24edfcb3..6e3b4244 100644 --- a/backend/notifications/senders/push.py +++ b/backend/notifications/senders/push.py @@ -72,6 +72,7 @@ class PushNotificationSender(BaseNotificationSender): "tag": f"notification-{notification.id}", "requireInteraction": False, "data": { + "url": notification.action_url or "/", "notification_id": notification.id, "verb": notification.verb, }, diff --git a/frontend/public/sw.js b/frontend/public/sw.js index a7e4dd9c..93baa213 100644 --- a/frontend/public/sw.js +++ b/frontend/public/sw.js @@ -6,7 +6,7 @@ * нативные уведомления даже когда страница закрыта. */ -const SW_VERSION = '2.1.0'; +const SW_VERSION = '2.1.1'; const STATIC_CACHE = `eusrr-static-${SW_VERSION}`; const PRECACHE_URLS = [ '/manifest.webmanifest', @@ -136,12 +136,20 @@ self.addEventListener('push', (event) => { notificationData = { ...notificationData, - title: payload.title || notificationData.title, + title: payload.title || payload.head || notificationData.title, body: payload.body || payload.message || '', icon: payload.icon || notificationData.icon, badge: payload.badge || notificationData.badge, tag: payload.tag || `notification-${Date.now()}`, - data: payload.data || {} + data: { + ...(payload.data || {}), + url: + payload.data?.url || + payload.url || + payload.action_url || + notificationData.data?.url || + '/', + } }; // Дополнительные опции