From 8af64e9370165d2e0d8a09fabf1dc6da71906c1d Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Tue, 22 Nov 2022 13:39:15 +0100 Subject: [PATCH] add events and expose them for webhooks (#2493) --- src/lib/addons/webhook-definition.ts | 18 ++++++++++++++++++ src/lib/services/feature-toggle-service.ts | 2 +- src/lib/types/events.ts | 10 ++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/lib/addons/webhook-definition.ts b/src/lib/addons/webhook-definition.ts index a4216ebc9d..afb035c30e 100644 --- a/src/lib/addons/webhook-definition.ts +++ b/src/lib/addons/webhook-definition.ts @@ -15,6 +15,15 @@ import { FEATURE_UPDATED, FEATURE_TAGGED, FEATURE_UNTAGGED, + CHANGE_REQUEST_CREATED, + CHANGE_REQUEST_DISCARDED, + CHANGE_ADDED, + CHANGE_DISCARDED, + CHANGE_REQUEST_APPROVED, + CHANGE_REQUEST_APPROVAL_ADDED, + CHANGE_REQUEST_CANCELLED, + CHANGE_REQUEST_SENT_TO_REVIEW, + CHANGE_REQUEST_APPLIED, } from '../types/events'; import { IAddonDefinition } from '../types/model'; @@ -87,6 +96,15 @@ const webhookDefinition: IAddonDefinition = { FEATURE_PROJECT_CHANGE, FEATURE_TAGGED, FEATURE_UNTAGGED, + CHANGE_REQUEST_CREATED, + CHANGE_REQUEST_DISCARDED, + CHANGE_ADDED, + CHANGE_DISCARDED, + CHANGE_REQUEST_APPROVED, + CHANGE_REQUEST_APPROVAL_ADDED, + CHANGE_REQUEST_CANCELLED, + CHANGE_REQUEST_SENT_TO_REVIEW, + CHANGE_REQUEST_APPLIED, ], }; diff --git a/src/lib/services/feature-toggle-service.ts b/src/lib/services/feature-toggle-service.ts index aaf428f16e..dd08744879 100644 --- a/src/lib/services/feature-toggle-service.ts +++ b/src/lib/services/feature-toggle-service.ts @@ -1035,7 +1035,7 @@ class FeatureToggleService { environment, )); if (canAddStrategies) { - await this.createStrategy( + await this.unprotectedCreateStrategy( getDefaultStrategy(featureName), { environment, diff --git a/src/lib/types/events.ts b/src/lib/types/events.ts index f644846bf2..afdcc21396 100644 --- a/src/lib/types/events.ts +++ b/src/lib/types/events.ts @@ -84,6 +84,16 @@ export const PUBLIC_SIGNUP_TOKEN_CREATED = 'public-signup-token-created'; export const PUBLIC_SIGNUP_TOKEN_USER_ADDED = 'public-signup-token-user-added'; export const PUBLIC_SIGNUP_TOKEN_TOKEN_UPDATED = 'public-signup-token-updated'; +export const CHANGE_REQUEST_CREATED = 'change-request-created'; +export const CHANGE_REQUEST_DISCARDED = 'change-request-discarded'; +export const CHANGE_ADDED = 'change-added'; +export const CHANGE_DISCARDED = 'change-discarded'; +export const CHANGE_REQUEST_APPROVED = 'change-request-approved'; +export const CHANGE_REQUEST_APPROVAL_ADDED = 'change-request-approval-added'; +export const CHANGE_REQUEST_CANCELLED = 'change-request-cancelled'; +export const CHANGE_REQUEST_SENT_TO_REVIEW = 'change-request-sent-to-review'; +export const CHANGE_REQUEST_APPLIED = 'change-request-applied'; + export interface IBaseEvent { type: string; createdBy: string;