From f52f9f7d3c712a8a7c30257e53c2069e2cc23b8a Mon Sep 17 00:00:00 2001 From: Gosha Date: Thu, 26 Dec 2024 00:33:46 +0200 Subject: [PATCH] fix(api): empty email preview --- .../usecases/generate-preview/generate-preview.usecase.ts | 1 - .../src/utils/sanitize-control-values.ts | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/api/src/app/workflows-v2/usecases/generate-preview/generate-preview.usecase.ts b/apps/api/src/app/workflows-v2/usecases/generate-preview/generate-preview.usecase.ts index cc78a1165db..1e225806aaa 100644 --- a/apps/api/src/app/workflows-v2/usecases/generate-preview/generate-preview.usecase.ts +++ b/apps/api/src/app/workflows-v2/usecases/generate-preview/generate-preview.usecase.ts @@ -23,7 +23,6 @@ import { dashboardSanitizeControlValues, } from '@novu/application-generic'; import { captureException } from '@sentry/node'; -import { getErrorPath as getErrorPathAjv } from 'ajv/dist/compile/util'; import { channelStepSchemas, actionStepSchemas } from '@novu/framework/internal'; import { PreviewStep, PreviewStepCommand } from '../../../bridge/usecases/preview-step'; import { FrameworkPreviousStepsOutputState } from '../../../bridge/usecases/preview-step/preview-step.command'; diff --git a/libs/application-generic/src/utils/sanitize-control-values.ts b/libs/application-generic/src/utils/sanitize-control-values.ts index 46787c3fe6d..c454d2bf61f 100644 --- a/libs/application-generic/src/utils/sanitize-control-values.ts +++ b/libs/application-generic/src/utils/sanitize-control-values.ts @@ -83,9 +83,14 @@ function sanitizeInApp(controlValues: InAppControlType) { } function sanitizeEmail(controlValues: EmailControlType) { + const EMPTY_TIP_TAP = JSON.stringify({ + type: 'doc', + content: [{ type: 'paragraph' }], + }); + const emailControls: EmailControlType = { subject: controlValues.subject, - body: controlValues.body, + body: isEmpty(controlValues.body) ? EMPTY_TIP_TAP : controlValues.body, skip: controlValues.skip || undefined, };