🐛 Skip pushing notification when ws is available

This commit is contained in:
2025-02-03 16:44:58 +08:00
parent bf7c10d195
commit a40ab9efdb
2 changed files with 5 additions and 21 deletions

View File

@ -99,7 +99,7 @@ func PushNotification(notification models.Notification, skipNotifiableCheck ...b
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err := proto.NewStreamServiceClient(gap.Nx.GetNexusGrpcConn()).PushStream(ctx, &proto.PushStreamRequest{
resp, err := proto.NewStreamServiceClient(gap.Nx.GetNexusGrpcConn()).PushStream(ctx, &proto.PushStreamRequest{
UserId: lo.ToPtr(uint64(notification.AccountID)),
Body: nex.WebSocketPackage{
Action: "notifications.new",
@ -111,6 +111,9 @@ func PushNotification(notification models.Notification, skipNotifiableCheck ...b
}
// Skip push notification
if resp.GetIsAllSuccess() {
return nil
}
if GetStatusDisturbable(notification.AccountID) != nil {
return nil
}