From c68fca9dd78a540aa77f4adc34e68d98ff4585de Mon Sep 17 00:00:00 2001 From: Krisztian Gacsal Date: Thu, 15 Aug 2024 13:36:49 +0200 Subject: [PATCH 1/3] fix: Notification enabled in Router config --- cmd/server/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/server/main.go b/cmd/server/main.go index 612a469b7..bb8830bb0 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -409,6 +409,7 @@ func main() { Notification: notificationService, // modules EntitlementsEnabled: conf.Entitlements.Enabled, + NotificationEnabled: conf.Notification.Enabled, }, RouterHook: func(r chi.Router) { r.Use(func(h http.Handler) http.Handler { From d1af279740e27e79a8041bad990ebb339e0e6ff5 Mon Sep 17 00:00:00 2001 From: Krisztian Gacsal Date: Thu, 15 Aug 2024 14:55:35 +0200 Subject: [PATCH 2/3] fix: return not found for deleted rule --- internal/notification/service.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/notification/service.go b/internal/notification/service.go index 7fe0925f4..5b8c1a616 100644 --- a/internal/notification/service.go +++ b/internal/notification/service.go @@ -8,6 +8,7 @@ import ( "github.com/openmeterio/openmeter/internal/notification/webhook" "github.com/openmeterio/openmeter/internal/productcatalog" + "github.com/openmeterio/openmeter/pkg/models" ) type Service interface { @@ -406,6 +407,16 @@ func (c service) CreateEvent(ctx context.Context, params CreateEventInput) (*Eve if err != nil { return nil, fmt.Errorf("failed to get rule: %w", err) } + + if rule.DeletedAt != nil { + return nil, NotFoundError{ + NamespacedID: models.NamespacedID{ + Namespace: params.Namespace, + ID: params.RuleID, + }, + } + } + if rule.Disabled { return nil, ValidationError{ Err: errors.New("failed to send event: rule is disabled"), From 49a9dd467e1bb9bd08e97c85e08bb83e8f966f96 Mon Sep 17 00:00:00 2001 From: Krisztian Gacsal Date: Thu, 15 Aug 2024 14:56:28 +0200 Subject: [PATCH 3/3] fix: event routing for webhook channels --- internal/notification/eventhandler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/notification/eventhandler.go b/internal/notification/eventhandler.go index d79b5e331..1e3f6b382 100644 --- a/internal/notification/eventhandler.go +++ b/internal/notification/eventhandler.go @@ -156,7 +156,7 @@ func (h *handler) dispatchWebhook(ctx context.Context, event *Event) error { Namespace: event.Namespace, EventID: event.ID, EventType: string(event.Type), - Channels: channelIDs, + Channels: []string{event.Rule.ID}, } switch event.Type {