⏪ Rollback skip push notify
This commit is contained in:
		@@ -100,7 +100,7 @@ func PushNotification(notification models.Notification, skipNotifiableCheck ...b
 | 
			
		||||
 | 
			
		||||
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
 | 
			
		||||
	defer cancel()
 | 
			
		||||
	resp, err := proto.NewStreamServiceClient(gap.Nx.GetNexusGrpcConn()).PushStream(ctx, &proto.PushStreamRequest{
 | 
			
		||||
	_, err := proto.NewStreamServiceClient(gap.Nx.GetNexusGrpcConn()).PushStream(ctx, &proto.PushStreamRequest{
 | 
			
		||||
		UserId: lo.ToPtr(uint64(notification.AccountID)),
 | 
			
		||||
		Body: nex.WebSocketPackage{
 | 
			
		||||
			Action:  "notifications.new",
 | 
			
		||||
@@ -112,9 +112,6 @@ func PushNotification(notification models.Notification, skipNotifiableCheck ...b
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Skip push notification
 | 
			
		||||
	if resp.GetIsAllSuccess() {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	if GetStatusDisturbable(notification.AccountID) != nil {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
@@ -135,8 +132,6 @@ func PushNotification(notification models.Notification, skipNotifiableCheck ...b
 | 
			
		||||
 | 
			
		||||
	log.Debug().Str("topic", notification.Topic).Any("uid", notification.AccountID).Msg("Pushing notify to user...")
 | 
			
		||||
 | 
			
		||||
	ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
 | 
			
		||||
	defer cancel()
 | 
			
		||||
	err = gap.Px.PushNotifyBatch(pushkit.NotificationPushBatchRequest{
 | 
			
		||||
		Providers:    providers,
 | 
			
		||||
		Tokens:       tokens,
 | 
			
		||||
@@ -195,7 +190,7 @@ func PushNotificationBatch(notifications []models.Notification, skipNotifiableCh
 | 
			
		||||
	stream := proto.NewStreamServiceClient(gap.Nx.GetNexusGrpcConn())
 | 
			
		||||
	for _, notification := range notifications {
 | 
			
		||||
		ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
 | 
			
		||||
		resp, err := stream.PushStream(ctx, &proto.PushStreamRequest{
 | 
			
		||||
		_, _ = stream.PushStream(ctx, &proto.PushStreamRequest{
 | 
			
		||||
			UserId: lo.ToPtr(uint64(notification.AccountID)),
 | 
			
		||||
			Body: nex.WebSocketPackage{
 | 
			
		||||
				Action:  "notifications.new",
 | 
			
		||||
@@ -204,10 +199,6 @@ func PushNotificationBatch(notifications []models.Notification, skipNotifiableCh
 | 
			
		||||
		})
 | 
			
		||||
		cancel()
 | 
			
		||||
 | 
			
		||||
		if err == nil && resp.GetIsAllSuccess() {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Skip push notification
 | 
			
		||||
		if GetStatusDisturbable(notification.AccountID) != nil {
 | 
			
		||||
			continue
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user