Skip to content

Commit

Permalink
Move env variable in function (#1272)
Browse files Browse the repository at this point in the history
* Refactor active campaign enable to a getter function

* Add change set
  • Loading branch information
MarcoPonchia authored Dec 10, 2024
1 parent 38fc70b commit fbd9da8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-dolls-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-cms": patch
---

Refactor move ACTIVE_CAMPAIGN_INTEGRATION_ENABLED env var in getter function
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -65,7 +66,7 @@ const validateDates = (event: IWebinarEvent): boolean => {
};

const validateSlug = async (event: IWebinarEvent): Promise<boolean> => {
if (!event.params.data.slug || !activeCampaignIntegrationIsEnabled) {
if (!event.params.data.slug || !getActiveCampaignIntegrationIsEnabled()) {
return true;
}

Expand Down Expand Up @@ -97,7 +98,7 @@ const createActiveCampaignList = async (
event: IWebinarEvent
): Promise<boolean> => {
if (
!activeCampaignIntegrationIsEnabled ||
!getActiveCampaignIntegrationIsEnabled() ||
!event.result?.slug ||
!event.result?.title
) {
Expand Down Expand Up @@ -150,7 +151,7 @@ const deleteActiveCampaignList = async (
event: IWebinarEvent
): Promise<boolean> => {
if (
!activeCampaignIntegrationIsEnabled ||
!getActiveCampaignIntegrationIsEnabled() ||
!event?.params.where ||
!event.params.where.id
) {
Expand Down Expand Up @@ -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'
);
Expand Down

0 comments on commit fbd9da8

Please sign in to comment.