(ctx context.Context, in *rotateSecretInput)
| 457 | } |
| 458 | |
| 459 | func (s *Server) handleRotateWebhookSecret(ctx context.Context, in *rotateSecretInput) (*rotateSecretOutput, error) { |
| 460 | user, err := s.requireAccountUser(ctx) |
| 461 | if err != nil { |
| 462 | return nil, err |
| 463 | } |
| 464 | _, body, err := runIdempotent(s, ctx, user.ID, in.IdempotencyKey, |
| 465 | "/v1/webhooks/"+in.ID+"/rotate-secret", nil, |
| 466 | func() (int, rotateSecretResponse, error) { |
| 467 | secret, prevExpires, rerr := s.deps.RotateSecret(ctx, in.ID, user.ID) |
| 468 | if rerr != nil { |
| 469 | if errors.Is(rerr, identity.ErrWebhookNotFound) { |
| 470 | return 0, rotateSecretResponse{}, NewError(http.StatusNotFound, "not_found", "webhook not found") |
| 471 | } |
| 472 | return 0, rotateSecretResponse{}, NewError(http.StatusInternalServerError, "internal_error", "failed to rotate webhook secret") |
| 473 | } |
| 474 | return http.StatusOK, rotateSecretResponse{ |
| 475 | SigningSecret: secret, |
| 476 | PreviousSecretExpiresAt: prevExpires.UTC().Format(time.RFC3339), |
| 477 | }, nil |
| 478 | }) |
| 479 | if err != nil { |
| 480 | return nil, err |
| 481 | } |
| 482 | return &rotateSecretOutput{Body: body}, nil |
| 483 | } |
| 484 | |
| 485 | func (s *Server) handleCreateWebhook(ctx context.Context, in *createWebhookInput) (*webhookCreateOutput, error) { |
| 486 | user, err := s.requireAccountUser(ctx) |
nothing calls this directly
no test coverage detected