MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / handleCreateWebhook

Method handleCreateWebhook

internal/httpapi/webhooks.go:485–512  ·  view source on GitHub ↗
(ctx context.Context, in *createWebhookInput)

Source from the content-addressed store, hash-verified

483}
484
485func (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
514func (s *Server) handleListWebhooks(ctx context.Context, _ *struct{}) (*listWebhooksOutput, error) {
515 user, err := s.requireAccountUser(ctx)

Callers

nothing calls this directly

Calls 6

requireAccountUserMethod · 0.95
validateWebhookFieldsMethod · 0.95
NewErrorFunction · 0.85
webhookViewFunction · 0.85
CreateWebhookMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected