Skip to content

Commit

Permalink
fix(application-generic): Use V2 Preferences critical flag only if …
Browse files Browse the repository at this point in the history
…it exists (#6563)
  • Loading branch information
rifont authored Sep 24, 2024
1 parent 7225753 commit 0eceddc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Get Control Schema - /step-schemas/:stepType (GET)', async () => {
it('should get control schema for email step', async function () {
const { body } = await session.testAgent.get(`/v1/step-schemas/${StepTypeEnum.EMAIL}`);

const schema = body.data.schema;
const { schema } = body.data;

expect(schema.type).to.equal('object');
expect(schema.properties).to.have.property('subject');
Expand Down
10 changes: 10 additions & 0 deletions apps/api/src/app/step-schemas/step-schemas.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { UserSessionData } from '@novu/shared';
import { ExternalApiAccessible, UserSession } from '@novu/application-generic';
import { StepType } from '@novu/framework';

import { ApiOperation, ApiParam } from '@nestjs/swagger';
import { GetStepSchemaCommand } from './usecases/get-step-schema/get-step-schema.command';
import { UserAuthentication } from '../shared/framework/swagger/api.key.security';
import { GetStepSchema } from './usecases/get-step-schema/get-step-schema.usecase';
Expand All @@ -16,6 +17,15 @@ export class StepSchemasController {
constructor(private getStepDefaultSchemaUsecase: GetStepSchema) {}

@Get('/:stepType')
@ApiOperation({
summary: 'Get step schema',
description: 'Get the schema for a step type',
})
@ApiParam({
name: 'stepType',
type: String,
description: 'The type of step to get the schema for.',
})
@ExternalApiAccessible()
async getStepSchema(
@UserSession() user: UserSessionData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ export class GetSubscriberTemplatePreference {

const template = mapTemplateConfiguration({
...command.template,
// determine if any readOnly constraints have been set by the Workflow owner
critical: GetPreferences.checkIfWorkflowPreferencesIsReadOnly(
subscriberWorkflowPreferences,
),
// Use the critical flag from the V2 Preference object if it exists
...(subscriberWorkflowPreferences && {
critical: GetPreferences.checkIfWorkflowPreferencesIsReadOnly(
subscriberWorkflowPreferences,
),
}),
});

return {
Expand Down

0 comments on commit 0eceddc

Please sign in to comment.