🐛 Bug fixes pushing notification skip stragry
This commit is contained in:
parent
a40ab9efdb
commit
7ff93f1344
@ -3,12 +3,13 @@ package services
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
||||||
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
|
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
|
||||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||||
"reflect"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
@ -194,7 +195,7 @@ func PushNotificationBatch(notifications []models.Notification, skipNotifiableCh
|
|||||||
stream := proto.NewStreamServiceClient(gap.Nx.GetNexusGrpcConn())
|
stream := proto.NewStreamServiceClient(gap.Nx.GetNexusGrpcConn())
|
||||||
for _, notification := range notifications {
|
for _, notification := range notifications {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
_, _ = stream.PushStream(ctx, &proto.PushStreamRequest{
|
resp, err := stream.PushStream(ctx, &proto.PushStreamRequest{
|
||||||
UserId: lo.ToPtr(uint64(notification.AccountID)),
|
UserId: lo.ToPtr(uint64(notification.AccountID)),
|
||||||
Body: nex.WebSocketPackage{
|
Body: nex.WebSocketPackage{
|
||||||
Action: "notifications.new",
|
Action: "notifications.new",
|
||||||
@ -203,6 +204,10 @@ func PushNotificationBatch(notifications []models.Notification, skipNotifiableCh
|
|||||||
})
|
})
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
|
if err == nil && resp.GetIsAllSuccess() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Skip push notification
|
// Skip push notification
|
||||||
if GetStatusDisturbable(notification.AccountID) != nil {
|
if GetStatusDisturbable(notification.AccountID) != nil {
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user