From 82fa877cadc5abf7912af28a94796edbe5c96e51 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 19 Mar 2025 21:29:14 +0800 Subject: [PATCH] :bug: Prevent duplicate device token be registered --- pkg/internal/services/notifications.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/internal/services/notifications.go b/pkg/internal/services/notifications.go index eefa8b5..edb5d07 100644 --- a/pkg/internal/services/notifications.go +++ b/pkg/internal/services/notifications.go @@ -25,6 +25,9 @@ func AddNotifySubscriber(user models.Account, provider, id, tk, ua string) (mode if err := database.C.Where(&models.NotificationSubscriber{ DeviceID: id, AccountID: user.ID, + }).Or(&models.NotificationSubscriber{ + DeviceToken: tk, + AccountID: user.ID, }).First(&prev).Error; err != nil { subscriber = models.NotificationSubscriber{ UserAgent: ua,