🔥 Remove ws connected does not push notify feature

This commit is contained in:
2024-06-08 20:11:58 +08:00
parent 5b06b2dccb
commit 6d035c1147
2 changed files with 4 additions and 9 deletions

View File

@ -58,19 +58,14 @@ func NewNotification(notification models.Notification) error {
}
func PushNotification(notification models.Notification) error {
frontendAvailable := false
for conn := range wsConn[notification.RecipientID] {
frontendAvailable = true
_ = conn.WriteMessage(1, models.UnifiedCommand{
Action: "notifications.new",
Payload: notification,
}.Marshal())
}
// Skip push notification when frontend notify is available
if frontendAvailable && !notification.IsForcePush {
return nil
}
// TODO Detect the push notification is turned off (still push when IsForcePush is on)
var subscribers []models.NotificationSubscriber
if err := database.C.Where(&models.NotificationSubscriber{