Add obligation webhooks

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-02-27 17:03:44 +01:00
parent 6905472fba
commit 6a83b53b47
11 changed files with 138 additions and 25 deletions

View File

@@ -24,6 +24,8 @@ import (
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/page"
"go.probo.inc/probo/pkg/validator"
"go.probo.inc/probo/pkg/webhook"
webhooktypes "go.probo.inc/probo/pkg/webhook/types"
)
type ObligationService struct {
@@ -160,6 +162,10 @@ func (s *ObligationService) Create(
return fmt.Errorf("cannot insert obligation: %w", err)
}
if err := webhook.InsertData(ctx, conn, s.svc.scope, req.OrganizationID, coredata.WebhookEventTypeObligationCreated, webhooktypes.NewObligation(obligation)); err != nil {
return fmt.Errorf("cannot insert webhook event: %w", err)
}
return nil
},
)
@@ -238,6 +244,10 @@ func (s *ObligationService) Update(
return fmt.Errorf("cannot update obligation: %w", err)
}
if err := webhook.InsertData(ctx, conn, s.svc.scope, obligation.OrganizationID, coredata.WebhookEventTypeObligationUpdated, webhooktypes.NewObligation(obligation)); err != nil {
return fmt.Errorf("cannot insert webhook event: %w", err)
}
return nil
},
)
@@ -261,6 +271,10 @@ func (s *ObligationService) Delete(
return fmt.Errorf("cannot load obligation: %w", err)
}
if err := webhook.InsertData(ctx, conn, s.svc.scope, obligation.OrganizationID, coredata.WebhookEventTypeObligationDeleted, webhooktypes.NewObligation(obligation)); err != nil {
return fmt.Errorf("cannot insert webhook event: %w", err)
}
if err := obligation.Delete(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot delete obligation: %w", err)
}