From a579eea7684bf28af8ea7de9b8efafe3703e4155 Mon Sep 17 00:00:00 2001 From: George Djabarov <39195835+djabarovgeorge@users.noreply.github.com> Date: Thu, 26 Dec 2024 08:39:36 +0200 Subject: [PATCH] fix(api-service): empty email preview (#7382) --- .../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, };