diff --git a/.changeset/cyan-dolls-reply.md b/.changeset/cyan-dolls-reply.md new file mode 100644 index 000000000..297cf6ee8 --- /dev/null +++ b/.changeset/cyan-dolls-reply.md @@ -0,0 +1,5 @@ +--- +"strapi-cms": patch +--- + +Refactor move ACTIVE_CAMPAIGN_INTEGRATION_ENABLED env var in getter function diff --git a/apps/strapi-cms/src/api/webinar/content-types/webinar/lifecycles.ts b/apps/strapi-cms/src/api/webinar/content-types/webinar/lifecycles.ts index 39085e59e..5bfe1df73 100644 --- a/apps/strapi-cms/src/api/webinar/content-types/webinar/lifecycles.ts +++ b/apps/strapi-cms/src/api/webinar/content-types/webinar/lifecycles.ts @@ -12,8 +12,9 @@ interface IActiveCampaignListPayload { }; } -const activeCampaignIntegrationIsEnabled = - env('ACTIVE_CAMPAIGN_INTEGRATION_IS_ENABLED', 'False') === 'True'; +function getActiveCampaignIntegrationIsEnabled() { + return env('ACTIVE_CAMPAIGN_INTEGRATION_ENABLED', 'false') === 'true'; +} function getHeaders() { return { @@ -65,7 +66,7 @@ const validateDates = (event: IWebinarEvent): boolean => { }; const validateSlug = async (event: IWebinarEvent): Promise => { - if (!event.params.data.slug || !activeCampaignIntegrationIsEnabled) { + if (!event.params.data.slug || !getActiveCampaignIntegrationIsEnabled()) { return true; } @@ -97,7 +98,7 @@ const createActiveCampaignList = async ( event: IWebinarEvent ): Promise => { if ( - !activeCampaignIntegrationIsEnabled || + !getActiveCampaignIntegrationIsEnabled() || !event.result?.slug || !event.result?.title ) { @@ -150,7 +151,7 @@ const deleteActiveCampaignList = async ( event: IWebinarEvent ): Promise => { if ( - !activeCampaignIntegrationIsEnabled || + !getActiveCampaignIntegrationIsEnabled() || !event?.params.where || !event.params.where.id ) { @@ -196,7 +197,7 @@ module.exports = { await deleteActiveCampaignList(event); }, beforeDeleteMany() { - if (activeCampaignIntegrationIsEnabled) { + if (getActiveCampaignIntegrationIsEnabled()) { throw new errors.ApplicationError( 'Bulk deletion is not allowed for webinars if Active Campaign integration is enabled' );