(ctx context.Context, in *createWebhookInput)
| 483 | } |
| 484 | |
| 485 | func (s *Server) handleCreateWebhook(ctx context.Context, in *createWebhookInput) (*webhookCreateOutput, error) { |
| 486 | user, err := s.requireAccountUser(ctx) |
| 487 | if err != nil { |
| 488 | return nil, err |
| 489 | } |
| 490 | var filters WebhookFiltersView |
| 491 | if in.Body.Filters != nil { |
| 492 | filters = *in.Body.Filters |
| 493 | } |
| 494 | if env := s.validateWebhookFields(ctx, user.ID, in.Body.URL, in.Body.Events, filters, in.Body.Description); env != nil { |
| 495 | return nil, env |
| 496 | } |
| 497 | wh, err := s.deps.CreateWebhook(ctx, user.ID, in.Body.URL, in.Body.Description, in.Body.Events, identity.WebhookFilters{ |
| 498 | AgentIDs: filters.AgentIDs, |
| 499 | ConversationIDs: filters.ConversationIDs, |
| 500 | Labels: filters.Labels, |
| 501 | }) |
| 502 | if err != nil { |
| 503 | if errors.Is(err, identity.ErrWebhookCapReached) { |
| 504 | return nil, NewError(http.StatusBadRequest, "webhook_cap_reached", err.Error()) |
| 505 | } |
| 506 | return nil, NewError(http.StatusInternalServerError, "internal_error", "failed to create webhook") |
| 507 | } |
| 508 | return &webhookCreateOutput{Body: CreateWebhookResponse{ |
| 509 | WebhookView: webhookView(wh), |
| 510 | SigningSecret: wh.SigningSecret, |
| 511 | }}, nil |
| 512 | } |
| 513 | |
| 514 | func (s *Server) handleListWebhooks(ctx context.Context, _ *struct{}) (*listWebhooksOutput, error) { |
| 515 | user, err := s.requireAccountUser(ctx) |
nothing calls this directly
no test coverage detected