From 648f10b25afff5a3cb66d7a570460ef5f125cfc0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 22 Sep 2024 01:27:57 +0800 Subject: [PATCH] :bug: Fix batch notification prefs querying issue --- pkg/internal/services/notifications.go | 2 +- pkg/internal/services/preferences.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/internal/services/notifications.go b/pkg/internal/services/notifications.go index f74d836..4dfb205 100644 --- a/pkg/internal/services/notifications.go +++ b/pkg/internal/services/notifications.go @@ -59,7 +59,7 @@ func NewNotification(notification models.Notification) error { if err := database.C.Save(¬ification).Error; err != nil { return err } - if err := PushNotification(notification); err != nil { + if err := PushNotification(notification, true); err != nil { return err } diff --git a/pkg/internal/services/preferences.go b/pkg/internal/services/preferences.go index fc977b5..72ce8ae 100644 --- a/pkg/internal/services/preferences.go +++ b/pkg/internal/services/preferences.go @@ -56,7 +56,9 @@ func CheckNotificationNotifiable(account models.Account, topic string) bool { func CheckNotificationNotifiableBatch(accounts []models.Account, topic string) []bool { var notifications []models.PreferenceNotification - if err := database.C.Where("account_id IN ?", accounts).Find(¬ifications).Error; err != nil { + if err := database.C.Where("account_id IN ?", lo.Map(accounts, func(item models.Account, index int) uint { + return item.ID + })).Find(¬ifications).Error; err != nil { return lo.Map(accounts, func(item models.Account, index int) bool { return false })