Skip to content

Commit

Permalink
set folderId to optional in environmental variables and handle undefi…
Browse files Browse the repository at this point in the history
…ned folderId
  • Loading branch information
Julia Wegmayr committed Dec 9, 2024
1 parent 4ee2760 commit c799c55
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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=
4 changes: 2 additions & 2 deletions demo/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
};
}
},
Expand Down
5 changes: 3 additions & 2 deletions demo/api/src/config/environment-variables.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -144,6 +144,7 @@ export class EnvironmentVariables {
CAMPAIGN_BASIC_AUTH_PASSWORD: string;

@IsNumber()
@IsUndefinable()
@Type(() => Number)
BREVO_FOLDER_ID: number;
BREVO_FOLDER_ID?: number;
}
2 changes: 1 addition & 1 deletion packages/api/src/brevo-api/brevo-api-contact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c799c55

Please sign in to comment.