1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: project to lifecycle events (#7400)

We need project for those events to filter it out in webhook
configuration.
This commit is contained in:
Jaanus Sellin 2024-06-14 16:42:10 +03:00 committed by GitHub
parent 803a55d103
commit c33901b332
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 6 deletions

View File

@ -143,12 +143,13 @@ export default class FeatureLifecycleController extends Controller {
if (!this.flagResolver.isEnabled('featureLifecycle')) {
throw new NotFoundError('Feature lifecycle is disabled.');
}
const { featureName } = req.params;
const { featureName, projectId } = req.params;
const status = req.body;
await this.featureLifecycleService.featureCompleted(
featureName,
projectId,
status,
req.audit,
);
@ -163,10 +164,11 @@ export default class FeatureLifecycleController extends Controller {
if (!this.flagResolver.isEnabled('featureLifecycle')) {
throw new NotFoundError('Feature lifecycle is disabled.');
}
const { featureName } = req.params;
const { featureName, projectId } = req.params;
await this.featureLifecycleService.featureUnCompleted(
await this.featureLifecycleService.featureUncompleted(
featureName,
projectId,
req.audit,
);

View File

@ -180,6 +180,7 @@ export class FeatureLifecycleService extends EventEmitter {
public async featureCompleted(
feature: string,
projectId: string,
status: FeatureLifecycleCompletedSchema,
auditUser: IAuditUser,
) {
@ -193,6 +194,7 @@ export class FeatureLifecycleService extends EventEmitter {
]);
await this.eventService.storeEvent(
new FeatureCompletedEvent({
project: projectId,
featureName: feature,
data: status,
auditUser,
@ -200,13 +202,18 @@ export class FeatureLifecycleService extends EventEmitter {
);
}
public async featureUnCompleted(feature: string, auditUser: IAuditUser) {
public async featureUncompleted(
feature: string,
projectId: string,
auditUser: IAuditUser,
) {
await this.featureLifecycleStore.deleteStage({
feature,
stage: 'completed',
});
await this.eventService.storeEvent(
new FeatureUncompletedEvent({
project: projectId,
featureName: feature,
auditUser,
}),

View File

@ -722,29 +722,35 @@ export class FeatureTagImport extends BaseEvent {
export class FeatureCompletedEvent extends BaseEvent {
readonly featureName: string;
readonly data: FeatureLifecycleCompletedSchema;
readonly project: string;
constructor(p: {
project: string;
featureName: string;
data: FeatureLifecycleCompletedSchema;
auditUser: IAuditUser;
}) {
super(FEATURE_COMPLETED, p.auditUser);
const { featureName, data } = p;
const { featureName, data, project } = p;
this.featureName = featureName;
this.data = data;
this.project = project;
}
}
export class FeatureUncompletedEvent extends BaseEvent {
readonly featureName: string;
readonly project: string;
constructor(p: {
featureName: string;
auditUser: IAuditUser;
project: string;
}) {
super(FEATURE_UNCOMPLETED, p.auditUser);
const { featureName } = p;
const { featureName, project } = p;
this.featureName = featureName;
this.project = project;
}
}