From c799c550aa330fc9a9d38c8882250905d1ad5971 Mon Sep 17 00:00:00 2001 From: Julia Wegmayr Date: Mon, 9 Dec 2024 09:44:24 +0100 Subject: [PATCH] set folderId to optional in environmental variables and handle undefined folderId --- .env | 2 +- demo/api/src/app.module.ts | 4 ++-- demo/api/src/config/environment-variables.ts | 5 +++-- packages/api/src/brevo-api/brevo-api-contact.service.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.env b/.env index 3b39eefd..b7c7dabd 100644 --- a/.env +++ b/.env @@ -85,4 +85,4 @@ NEXT_PUBLIC_CAMPAIGN_IS_PREVIEW=false REDIRECT_URL_FOR_IMPORT=$SITE_URL BREVO_ALLOWED_REDIRECT_URL=http://${DEV_DOMAIN:-localhost}${WORKAROUND_DOTENV_ISSUE}:${SITE_PORT} CAMPAIGNS_FRONTEND_URL=http://${DEV_DOMAIN:-localhost}${WORKAROUND_DOTENV_ISSUE}:${SITE_PORT} # doesn't work, TODO: add actual mailing frontend -BREVO_FOLDER_ID=457 +BREVO_FOLDER_ID= diff --git a/demo/api/src/app.module.ts b/demo/api/src/app.module.ts index 1be1b434..1d0723ef 100644 --- a/demo/api/src/app.module.ts +++ b/demo/api/src/app.module.ts @@ -148,7 +148,7 @@ export class AppModule { sender: { name: config.brevo.sender.name, email: config.brevo.sender.email }, allowedRedirectUrl: config.brevo.allowedRedirectUrl, redirectUrlForImport: config.brevo.redirectUrlForImport, - folderId: config.brevo.folderId, + folderId: config.brevo.folderId ?? 1, }; } else { return { @@ -157,7 +157,7 @@ export class AppModule { sender: { name: config.brevo.sender.name, email: config.brevo.sender.email }, allowedRedirectUrl: config.brevo.allowedRedirectUrl, redirectUrlForImport: config.brevo.redirectUrlForImport, - folderId: config.brevo.folderId, + folderId: config.brevo.folderId ?? 1, // folderId is required, folder #1 is created by default }; } }, diff --git a/demo/api/src/config/environment-variables.ts b/demo/api/src/config/environment-variables.ts index 3f218473..23f92d70 100644 --- a/demo/api/src/config/environment-variables.ts +++ b/demo/api/src/config/environment-variables.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { BlobStorageConfig } from "@comet/cms-api"; +import { BlobStorageConfig, IsUndefinable } from "@comet/cms-api"; import { Transform, Type } from "class-transformer"; import { IsBase64, IsBoolean, IsEmail, IsInt, IsNumber, IsOptional, IsString, MinLength, ValidateIf } from "class-validator"; @@ -144,6 +144,7 @@ export class EnvironmentVariables { CAMPAIGN_BASIC_AUTH_PASSWORD: string; @IsNumber() + @IsUndefinable() @Type(() => Number) - BREVO_FOLDER_ID: number; + BREVO_FOLDER_ID?: number; } diff --git a/packages/api/src/brevo-api/brevo-api-contact.service.ts b/packages/api/src/brevo-api/brevo-api-contact.service.ts index a0490eed..d4f3179a 100644 --- a/packages/api/src/brevo-api/brevo-api-contact.service.ts +++ b/packages/api/src/brevo-api/brevo-api-contact.service.ts @@ -191,7 +191,7 @@ export class BrevoApiContactsService { try { const contactList = { name: title, - folderId: folderId ?? 1, // folderId is required, folder #1 is created by default + folderId: folderId, }; const data = await this.getContactsApi(scope).createList(contactList);