Skip to content

Commit ddffc88

Browse files
committed
fix
1 parent 31eb39b commit ddffc88

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

components/usage/pkg/apiv1/billing.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type BillingService struct {
4242
stripePrices stripe.StripePrices
4343

4444
teamsService v1connect.TeamsServiceClient
45+
userService v1connect.UserServiceClient
4546

4647
v1.UnimplementedBillingServiceServer
4748
}
@@ -475,7 +476,16 @@ func (s *BillingService) OnChargeDispute(ctx context.Context, req *v1.OnChargeDi
475476
logger = logger.WithField("teamOwners", userIDsToBlock)
476477

477478
logger.Infof("Identified %d users to block based on charge dispute", len(userIDsToBlock))
478-
// TODO: actually block users
479+
var errs []error
480+
for _, userToBlock := range userIDsToBlock {
481+
_, err := s.userService.BlockUser(ctx, connect.NewRequest(&experimental_v1.BlockUserRequest{
482+
UserId: userToBlock,
483+
Reason: fmt.Sprintf("User has created a Stripe dispute ID: %s", req.GetDisputeId()),
484+
}))
485+
if err != nil {
486+
errs = append(errs, fmt.Errorf("failed to block user %s: %w", userToBlock, err))
487+
}
488+
}
479489

480490
return &v1.OnChargeDisputeResponse{}, nil
481491
}

0 commit comments

Comments
 (0)